Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed interaction with directories #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/AzureBlobStorageAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
use MicrosoftAzure\Storage\Blob\Models\ListBlobsOptions;
use MicrosoftAzure\Storage\Common\Exceptions\ServiceException;
use MicrosoftAzure\Storage\Common\Models\ContinuationToken;
use function array_merge;
use function compact;
use function stream_get_contents;
use function strpos;
use function var_dump;

class AzureBlobStorageAdapter extends AbstractAdapter
{
Expand Down Expand Up @@ -130,6 +125,14 @@ public function deleteDir($dirname)

public function createDir($dirname, Config $config)
{
/**
* We need to do this recursively, if we don't directory checks will return unintuitive results.
* Since we emulate directories, this should always hold: is_dir('a/b/c') => is_dir('a/b').
*/
do {
$this->write(rtrim($dirname, '/') . '/', 'directory placeholder', $config);
$dirname = dirname($dirname);
} while ($dirname !== '.');
return ['path' => $dirname, 'type' => 'dir'];
}

Expand Down Expand Up @@ -226,7 +229,11 @@ public function getMetadata($path)
if ($exception->getCode() !== 404) {
throw $exception;
}

// If the path does not exist try the directory
if (substr($path, -1) !== '/') {
$result = $this->getMetadata($path . '/');
return $result;
}
return false;
}
}
Expand Down