Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Fix: Handle duplicate containers across accounts #2596

Merged
merged 1 commit into from
Nov 3, 2022
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
22 changes: 11 additions & 11 deletions src/ApiService/ApiService/onefuzzlib/Containers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,17 @@ public async Async.Task<bool> BlobExists(Container container, string name, Stora
}

public async Task<Dictionary<Container, IDictionary<string, string>>> GetContainers(StorageType corpus) {
var accounts = _storage.GetAccounts(corpus);
IEnumerable<IEnumerable<KeyValuePair<Container, IDictionary<string, string>>>> data =
await Async.Task.WhenAll(accounts.Select(async acc => {
var service = await _storage.GetBlobServiceClientForAccount(acc);
return await service
.GetBlobContainersAsync(BlobContainerTraits.Metadata)
.Select(container => KeyValuePair.Create(Container.Parse(container.Name), container.Properties.Metadata))
.ToListAsync();
}));

return new(data.SelectMany(x => x));
var result = new Dictionary<Container, IDictionary<string, string>>();

// same container name can exist in multiple accounts; here the last one wins
foreach (var account in _storage.GetAccounts(corpus)) {
var service = await _storage.GetBlobServiceClientForAccount(account);
await foreach (var container in service.GetBlobContainersAsync(BlobContainerTraits.Metadata)) {
result[Container.Parse(container.Name)] = container.Properties.Metadata;
}
}

return result;
}

public string AuthDownloadUrl(Container container, string filename) {
Expand Down