aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Transfers
diff options
context:
space:
mode:
Diffstat (limited to 'src/slskd/Transfers')
-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(() =>
{