From 3595b00409b6a0753637091948a3c8d7439841e1 Mon Sep 17 00:00:00 2001 From: Anna Date: Fri, 8 Sep 2023 23:18:40 -0400 Subject: [PATCH] fix: handle duplicate hashes in batched downloads --- DownloadTask.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DownloadTask.cs b/DownloadTask.cs index 528274b..1006414 100644 --- a/DownloadTask.cs +++ b/DownloadTask.cs @@ -225,10 +225,13 @@ private IEnumerable DownloadNormalFiles(IDownloadTask_GetVersion_NeededFil private IEnumerable 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(); 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); } }