aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2025-10-09 19:02:39 -0500
committerJP Dillingham <jp@dillingham.me>2025-10-09 19:02:39 -0500
commit0273fb1fdde5f01fc0a545eadb0da23f62ed01ac (patch)
tree8f3651d8d16dfc57914cc63455efbba061133209 /src/slskd
parentde5103fb7db29a9fff95604de883fd4886e47c88 (diff)
downloadslskd-0273fb1fdde5f01fc0a545eadb0da23f62ed01ac.tar.gz
move stateChanged delegate invoke to finally
Diffstat (limited to 'src/slskd')
-rw-r--r--src/slskd/Transfers/Downloads/DownloadService.cs41
1 files changed, 23 insertions, 18 deletions
diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs
index db1a92ad..65404945 100644
--- a/src/slskd/Transfers/Downloads/DownloadService.cs
+++ b/src/slskd/Transfers/Downloads/DownloadService.cs
@@ -279,29 +279,34 @@ namespace slskd.Transfers.Downloads
var topts = new TransferOptions(
stateChanged: (args) =>
{
- Log.Debug("Download of {Filename} from user {Username} changed state from {Previous} to {New}", transfer.Filename, transfer.Username, args.PreviousState, args.Transfer.State);
-
- // prevent Exceptions thrown during shutdown from updating the transfer record with related Exceptions;
- // instead, allow these to be left "hanging" so that they are properly cleaned up at the next startup
- if (Application.IsShuttingDown)
+ try
{
- Log.Debug("Download update of {Filename} to {Username} not persisted; app is shutting down", transfer.Filename, transfer.Username);
- return;
- }
+ Log.Debug("Download of {Filename} from user {Username} changed state from {Previous} to {New}", transfer.Filename, transfer.Username, args.PreviousState, args.Transfer.State);
- transfer = transfer.WithSoulseekTransfer(args.Transfer);
+ // prevent Exceptions thrown during shutdown from updating the transfer record with related Exceptions;
+ // instead, allow these to be left "hanging" so that they are properly cleaned up at the next startup
+ if (Application.IsShuttingDown)
+ {
+ Log.Debug("Download update of {Filename} to {Username} not persisted; app is shutting down", transfer.Filename, transfer.Username);
+ return;
+ }
- // we don't know when the download is actually enqueued (remotely) until it switches into that state
- // when it is enqueued locally is irrelevant, due to internal throttling etc
- if (args.Transfer.State.HasFlag(TransferStates.Queued) && args.Transfer.State.HasFlag(TransferStates.Remotely))
- {
- transfer.EnqueuedAt ??= DateTime.UtcNow;
- }
+ transfer = transfer.WithSoulseekTransfer(args.Transfer);
- // todo: broadcast
- SynchronizedUpdate(transfer);
+ // we don't know when the download is actually enqueued (remotely) until it switches into that state
+ // when it is enqueued locally is irrelevant, due to internal throttling etc
+ if (args.Transfer.State.HasFlag(TransferStates.Queued) && args.Transfer.State.HasFlag(TransferStates.Remotely))
+ {
+ transfer.EnqueuedAt ??= DateTime.UtcNow;
+ }
- stateChanged?.Invoke(transfer);
+ // todo: broadcast
+ SynchronizedUpdate(transfer);
+ }
+ finally
+ {
+ stateChanged?.Invoke(transfer);
+ }
},
progressUpdated: (args) => rateLimiter.Invoke(() =>
{