From 3ad70da8345653dd004cc1ae588ac05753da9005 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 19 Oct 2025 12:28:06 -0500 Subject: prime connection before enqueueing locally --- src/slskd/Transfers/Downloads/DownloadService.cs | 26 +++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs index a84a494d..a46130c9 100644 --- a/src/slskd/Transfers/Downloads/DownloadService.cs +++ b/src/slskd/Transfers/Downloads/DownloadService.cs @@ -532,6 +532,18 @@ namespace slskd.Transfers.Downloads throw; } + // prime the cache for this user, to 1) make sure we can connect, and 2) avoid needing to race for it in the loop + try + { + Log.Debug("Priming message connection to {Username}", username); + await Client.ConnectToUserAsync(username, invalidateCache: false, cancellationToken); + } + catch (Exception ex) + { + Log.Error(ex, "Failed to connect to {Username}: {Message}", username, ex.Message); + throw; + } + List acquiredLocks = []; try @@ -647,20 +659,6 @@ namespace slskd.Transfers.Downloads return (enqueued, failed); } - Log.Debug("Attempting to remotely enqueue {Count} files from {Username}", enqueued.Count, username); - - // prime the cache for this user, to 1) make sure we can connect, and 2) avoid needing to race for it in the loop - try - { - Log.Debug("Priming message connection to {Username}", username); - await Client.ConnectToUserAsync(username, invalidateCache: false, cancellationToken); - } - catch (Exception ex) - { - Log.Error(ex, "Failed to connect to {Username}: {Message}", username, ex.Message); - throw; - } - /* the files are all now in the database in the Queued | Locally state. -- cgit v1.2.3