diff options
| author | JP Dillingham <jp@dillingham.me> | 2025-10-26 17:34:24 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2025-10-26 17:34:24 -0500 |
| commit | 3f45b49277f440a671d9b736a020a921cb778620 (patch) | |
| tree | 83b8bb18ada5f3fd85c9bb65ebd2cd1a30fbe7ed /src | |
| parent | c4a7f71d0b0b9e4bdff33bb9eb6145a1d783cb78 (diff) | |
| download | slskd-3f45b49277f440a671d9b736a020a921cb778620.tar.gz | |
feedback
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Transfers/Downloads/DownloadService.cs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs index 9b36f5ec..f09b3c13 100644 --- a/src/slskd/Transfers/Downloads/DownloadService.cs +++ b/src/slskd/Transfers/Downloads/DownloadService.cs @@ -849,10 +849,9 @@ namespace slskd.Transfers.Downloads // there _should_ be a cancellation token for this transfer in the dictionary; if so link it with the one we are given // (which is probably the same one, harmless if so) to make sure we don't get any wires crossed - if (CancellationTokens.TryGetValue(transfer.Id, out var cancellationTokenSource)) - { - cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken).Token; - } + CancellationTokens.TryGetValue(transfer.Id, out var cancellationTokenSource); + using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, cancellationTokenSource?.Token ?? CancellationToken.None); + cancellationToken = cts.Token; var updateSyncRoot = new SemaphoreSlim(1, 1); @@ -958,7 +957,7 @@ namespace slskd.Transfers.Downloads Log.Debug("Invocation of Soulseek DownloadAsync() for {Filename} from user {Username} completed successfully", transfer.Filename, transfer.Username); // explicitly dispose the rate limiter to prevent updates from it beyond this point, and in doing so we - // flushe any pending update, _probably_ pushing the state of the transfer back to InProgress + // flush any pending update, _probably_ pushing the state of the transfer back to InProgress rateLimiter.Dispose(); // copy the completed transfer that was returned from Soulseek.NET in a terminal, fully updated state @@ -1063,9 +1062,9 @@ namespace slskd.Transfers.Downloads } finally { - if (CancellationTokens.TryRemove(transfer.Id, out var cts)) + if (CancellationTokens.TryRemove(transfer.Id, out var storedCancellationTokenSource)) { - cts?.Dispose(); + storedCancellationTokenSource?.Dispose(); } } } @@ -1096,7 +1095,7 @@ namespace slskd.Transfers.Downloads { EnqueueSemaphores.TryRemove(kvp.Key, out var removed); removed.Dispose(); - Log.Debug($"Cleaned up enqueue semaphore for {kvp.Key}"); + Log.Debug("Cleaned up enqueue semaphore for {Key}", kvp.Key); } } } |
