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

VCST-1785: Error while Generating Thumbnail Due to Duplicate File Names with Encoded Characters #112

Merged
merged 2 commits into from
Sep 9, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,36 @@ protected virtual async Task<ConcurrentDictionary<string, BlobEntry>> ReadBlobFo

var searchResults = await _storageProvider.SearchAsync(folderPath, null);

result.AddRange(searchResults.Results.Where(item => _supportedImageExtensions.Contains(Path.GetExtension(item.Name).ToLowerInvariant())).Select(x => KeyValuePair.Create(x.Url, x)));
// Add supported images
foreach (var imageBlob in searchResults.Results.Where(IsSupportedImage))
{
result.TryAdd(imageBlob.Url, imageBlob);
}

await Parallel.ForEachAsync(searchResults.Results.Where(x => x.Type == "folder"), async (blobFolder, token) =>
// Add images from child folders recursively
await Parallel.ForEachAsync(searchResults.Results.Where(IsFolder), async (folderBlob, token) =>
{
var folderResult = await ReadBlobFolderAsync(blobFolder.RelativeUrl, new CancellationTokenWrapper(token));
var childFolderImages = await ReadBlobFolderAsync(folderBlob.RelativeUrl, new CancellationTokenWrapper(token));

result.AddRange(folderResult);
foreach (var imageBlob in childFolderImages.Values)
{
result.TryAdd(imageBlob.Url, imageBlob);
}
});

return result;
}

protected virtual bool IsSupportedImage(BlobEntry blobEntry)
{
return _supportedImageExtensions.Contains(Path.GetExtension(blobEntry.Name), StringComparer.OrdinalIgnoreCase);
}

protected virtual bool IsFolder(BlobEntry blobEntry)
{
return blobEntry.Type.EqualsIgnoreCase("folder");
}

protected virtual async Task<EntryState> GetItemStateAsync(
BlobEntry blobInfo,
DateTime? changedSince,
Expand Down
Loading