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

Fix BlobFileStore (#3280) #3336

Merged
merged 1 commit into from
Mar 15, 2019
Merged
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
20 changes: 17 additions & 3 deletions src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,10 @@ public async Task<IFileStoreEntry> GetDirectoryInfoAsync(string path)
{
await _verifyContainerTask;

var placeholderBlob = GetBlobReference(this.Combine(path, _directoryMarkerFileName));
var blobDirectory = GetBlobDirectoryReference(path);

if (await placeholderBlob.ExistsAsync())
if (path == string.Empty || await BlobDirectoryExists(blobDirectory))
{
var blobDirectory = GetBlobDirectoryReference(path);
return new BlobDirectory(path, _clock.UtcNow);
}
return null;
Expand Down Expand Up @@ -299,6 +298,21 @@ await placeholderBlob.UploadTextAsync(
"This is a directory marker file created by Orchard Core. It is safe to delete it.");
}

private async Task<bool> BlobDirectoryExists(CloudBlobDirectory blobDirectory)
{
// CloudBlobDirectory exists if it has at least one blob
BlobContinuationToken continuationToken = null;
var segment = await blobDirectory.ListBlobsSegmentedAsync(
useFlatBlobListing: false,
blobListingDetails: BlobListingDetails.None,
maxResults: 1,
currentToken: continuationToken,
options: null,
operationContext: null);

return segment.Results.Any();
}

private async Task CreateBasePathIfNotExistsAsync()
{
if (string.IsNullOrEmpty(_options.BasePath))
Expand Down