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

Commit

Permalink
Handle duplicate containers across accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Porges committed Nov 3, 2022
1 parent 22cb201 commit d548b86
Showing 1 changed file with 11 additions and 11 deletions.
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

0 comments on commit d548b86

Please sign in to comment.