aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-11-12 18:54:25 -0600
committerJP Dillingham <jp@dillingham.me>2026-11-12 18:54:25 -0600
commit08c378db4f81f0d4147c35be172617393b9d005b (patch)
tree958fe26c0982f0900c1b03377c8a6192db905257
parent41b84b1b29fe2c2ee403cc2da99349708e79c21b (diff)
downloadslskd-08c378db4f81f0d4147c35be172617393b9d005b.tar.gz
fail the enqueue wait if DownloadAsync() fails
-rw-r--r--src/slskd/Transfers/Downloads/DownloadService.cs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs
index e7102dc1..2b8bbf8d 100644
--- a/src/slskd/Transfers/Downloads/DownloadService.cs
+++ b/src/slskd/Transfers/Downloads/DownloadService.cs
@@ -505,6 +505,7 @@ namespace slskd.Transfers.Downloads
2. the transfer enters a state containing Completed
3. the linked CancellationTokenSource we add to CancellationTokens is cancelled
4. the 'max wait time' CancellationTokenSource is cancelled
+ 5. the DownloadAsync() method throws
add this to the dictionary before inserting the record, so we are guaranteed to have it
in the right place once the transfer hits the UI
@@ -599,6 +600,10 @@ namespace slskd.Transfers.Downloads
Log.Error(ex, "Task for download of {Filename} from {Username} did not complete successfully: {Error}", file.Filename, username, ex.Message);
+ // trip the TCS if DownloadAsync() throws before any of the other conditions trip it
+ // this is harmless if it has already been tripped
+ enqueuedTcs.TrySetException(ex);
+
if (!TryFail(transferId, exception: ex))
{
Log.Error(ex, "Failed to clean up transfer {Id} after failed download", transferId);
@@ -616,6 +621,7 @@ namespace slskd.Transfers.Downloads
2. the transfer enters a state containing Completed
3. the linked CancellationTokenSource we add to CancellationTokens is cancelled
4. the 'max wait time' CancellationTokenSource is cancelled
+ 5. the DownloadAsync() method throws
*/
await enqueuedTcs.Task;