diff options
| author | JP Dillingham <jp@dillingham.me> | 2025-09-21 19:15:58 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2025-09-21 19:15:58 -0500 |
| commit | 33f1a327ad3e3348f1981d2a5b14c6648201451f (patch) | |
| tree | 1fa768b118c7f0b0ec6ce121343ed1aca877b15e /src | |
| parent | cd71cde4b8e4693a07afbc178c91259bb0ff4d9e (diff) | |
| download | slskd-33f1a327ad3e3348f1981d2a5b14c6648201451f.tar.gz | |
add Trycomplete
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Transfers/Uploads/UploadQueue.cs | 32 |
1 files changed, 32 insertions, 0 deletions
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 @@ -50,6 +50,15 @@ namespace slskd.Transfers void Complete(string username, string filename); /// <summary> + /// Gracefully attempts to signal the completion of an upload, returning false if a problem is encountered + /// (such as the upload not being tracked currently). + /// </summary> + /// <param name="username">The username of the remote user.</param> + /// <param name="filename">The completed filename.</param> + /// <returns>A value indicating whether a problem was encountered.</returns> + bool TryComplete(string username, string filename); + + /// <summary> /// Enqueues an upload. /// </summary> /// <param name="username">The username of the remote user.</param> @@ -152,8 +161,31 @@ namespace slskd.Transfers } /// <summary> + /// Gracefully attempts to signal the completion of an upload, returning false if a problem is encountered + /// (such as the upload not being tracked currently). + /// </summary> + /// <param name="username">The username of the remote user.</param> + /// <param name="filename">The completed filename.</param> + /// <returns>A value indicating whether a problem was encountered.</returns> + public bool TryComplete(string username, string filename) + { + try + { + Complete(username, filename); + return true; + } + catch (SlskdException) + { + return false; + } + } + + /// <summary> /// Signals the completion of an upload. /// </summary> + /// <remarks> + /// Will not throw on repeated attempts. + /// </remarks> /// <param name="username">The username of the remote user.</param> /// <param name="filename">The completed filename.</param> public void Complete(string username, string filename) |
