From 33f1a327ad3e3348f1981d2a5b14c6648201451f Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 21 Sep 2025 19:15:58 -0500 Subject: add Trycomplete --- src/slskd/Transfers/Uploads/UploadQueue.cs | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src') diff --git a/src/slskd/Transfers/Uploads/UploadQueue.cs b/src/slskd/Transfers/Uploads/UploadQueue.cs index c24f66cf..c20e2312 100644 --- a/src/slskd/Transfers/Uploads/UploadQueue.cs +++ b/src/slskd/Transfers/Uploads/UploadQueue.cs @@ -49,6 +49,15 @@ namespace slskd.Transfers /// The completed filename. void Complete(string username, string filename); + /// + /// Gracefully attempts to signal the completion of an upload, returning false if a problem is encountered + /// (such as the upload not being tracked currently). + /// + /// The username of the remote user. + /// The completed filename. + /// A value indicating whether a problem was encountered. + bool TryComplete(string username, string filename); + /// /// Enqueues an upload. /// @@ -151,9 +160,32 @@ namespace slskd.Transfers } } + /// + /// Gracefully attempts to signal the completion of an upload, returning false if a problem is encountered + /// (such as the upload not being tracked currently). + /// + /// The username of the remote user. + /// The completed filename. + /// A value indicating whether a problem was encountered. + public bool TryComplete(string username, string filename) + { + try + { + Complete(username, filename); + return true; + } + catch (SlskdException) + { + return false; + } + } + /// /// Signals the completion of an upload. /// + /// + /// Will not throw on repeated attempts. + /// /// The username of the remote user. /// The completed filename. public void Complete(string username, string filename) -- cgit v1.2.3