aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/slskd/Transfers/Downloads/DownloadService.cs2
-rw-r--r--tests/slskd.Tests.Unit/Transfers/Downloads/DownloadService/EnqueueAsyncTests.cs11
2 files changed, 12 insertions, 1 deletions
diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs
index 32744fb2..707221ac 100644
--- a/src/slskd/Transfers/Downloads/DownloadService.cs
+++ b/src/slskd/Transfers/Downloads/DownloadService.cs
@@ -324,7 +324,7 @@ namespace slskd.Transfers.Downloads
throw new ArgumentException("One or more files contains a dangerous path traversal segment", nameof(files));
}
- if (fileList.Count != fileList.Distinct().Count())
+ if (fileList.Count != fileList.Select(f => f.Filename).Distinct().Count())
{
throw new ArgumentException("Two or more files in request are duplicated", nameof(files));
}
diff --git a/tests/slskd.Tests.Unit/Transfers/Downloads/DownloadService/EnqueueAsyncTests.cs b/tests/slskd.Tests.Unit/Transfers/Downloads/DownloadService/EnqueueAsyncTests.cs
index 11edf035..6c1cb963 100644
--- a/tests/slskd.Tests.Unit/Transfers/Downloads/DownloadService/EnqueueAsyncTests.cs
+++ b/tests/slskd.Tests.Unit/Transfers/Downloads/DownloadService/EnqueueAsyncTests.cs
@@ -243,6 +243,17 @@ public partial class DownloadServiceTests
}
[Fact]
+ public async Task Throws_ArgumentException_When_Filenames_Are_Duplicated_With_Different_Sizes()
+ {
+ using var fixture = new Fixture();
+
+ var ex = await Record.ExceptionAsync(() => fixture.Service.EnqueueAsync(Username, [(Filename, Size), (Filename, Size + 1)]));
+
+ Assert.Contains("duplicated", Assert.IsType<ArgumentException>(ex).Message);
+ Assert.Empty(fixture.Records());
+ }
+
+ [Fact]
public async Task Rethrows_When_User_Endpoint_Lookup_Fails()
{
using var fixture = new Fixture();