Skip to content

Commit

Permalink
fix: handle duplicate hashes in batched downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-is-cute committed Sep 9, 2023
1 parent 9a27d7c commit 3595b00
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion DownloadTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,13 @@ private IEnumerable<Task> DownloadNormalFiles(IDownloadTask_GetVersion_NeededFil
private IEnumerable<Task> DownloadBatchedFiles(IDownloadTask_GetVersion_NeededFiles neededFiles, BatchList batches, string filesPath) {
var neededHashes = neededFiles.Files.Files.Keys.ToList();
var clonedBatches = batches.Files.ToDictionary(pair => pair.Key, pair => pair.Value.ToDictionary(pair => pair.Key, pair => pair.Value));
var seenHashes = new List<string>();
foreach (var (batch, files) in batches.Files) {
// remove any hashes that aren't needed
foreach (var hash in files.Keys) {
if (!neededHashes.Contains(hash)) {
if (neededHashes.Contains(hash) && !seenHashes.Contains(hash)) {
seenHashes.Add(hash);
} else {
clonedBatches[batch].Remove(hash);
}
}
Expand Down

0 comments on commit 3595b00

Please sign in to comment.