aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2025-10-22 07:56:51 -0500
committerJP Dillingham <jp@dillingham.me>2025-10-22 07:56:51 -0500
commite00dffb4ce2856ec9bf3559770b8d558d9643718 (patch)
treedd2e1b9fa55658d8c8d21679e85f5777103d0f1f /src
parent6bcc23c1856f9878509c940cc37b5d4fdb90e2d4 (diff)
downloadslskd-e00dffb4ce2856ec9bf3559770b8d558d9643718.tar.gz
remove locking fron DownloadAsync
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Transfers/Downloads/DownloadService.cs26
1 files changed, 1 insertions, 25 deletions
diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs
index 015ec384..d617befe 100644
--- a/src/slskd/Transfers/Downloads/DownloadService.cs
+++ b/src/slskd/Transfers/Downloads/DownloadService.cs
@@ -213,14 +213,6 @@ namespace slskd.Transfers.Downloads
var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
var syncRoot = new SemaphoreSlim(1, 1);
- var lockName = $"{nameof(DownloadAsync)}:{transfer.Username}:{transfer.Filename}";
-
- if (!Locks.TryAdd(lockName, true))
- {
- Log.Debug("Download attempt failed; lock {LockName} already held", lockName);
- throw new DuplicateTransferException("A duplicate download of the same file to the same user is already in progress");
- }
-
/*
from this point forward, any exit from this method MUST result in an update to the Transfer record
in the database that sets EndedAt and ensures that the State property includes the Completed flag
@@ -231,8 +223,6 @@ namespace slskd.Transfers.Downloads
*/
try
{
- Log.Debug("Acquired lock {LockName}", lockName);
-
/*
fetch an updated copy of the transfer record from the database; now that we are locked, we *should*
have exclusive access to this record
@@ -477,21 +467,7 @@ namespace slskd.Transfers.Downloads
}
finally
{
- Log.Debug("Finalizing download of {Filename} from {Username}", transfer.Filename, transfer.Username);
-
- try
- {
- Locks.TryRemove(lockName, out _);
- Log.Debug("Released lock {LockName}", lockName);
-
- CancellationTokens.TryRemove(transfer.Id, out _);
-
- Log.Debug("Finalization of download of {Filename} from {Username} completed", transfer.Filename, transfer.Username);
- }
- catch (Exception ex)
- {
- Log.Error(ex, "Failed to finalize download of {Filename} from {Username}: {Message}", transfer.Filename, transfer.Username, ex.Message);
- }
+ CancellationTokens.TryRemove(transfer.Id, out _);
}
}