diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-10-18 15:42:46 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-10-18 15:42:46 -0500 |
| commit | c5c2597ef63a02f59d6f1872c3bed4f7e9336c0f (patch) | |
| tree | 915b79d710131cc14fa68b26bf79a12763749f9b /src | |
| parent | 075f690419fc4fa0c706dfbdf1797e35a02f7a7e (diff) | |
| download | slskd-c5c2597ef63a02f59d6f1872c3bed4f7e9336c0f.tar.gz | |
use Query() within List()
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Transfers/Uploads/UploadService.cs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/slskd/Transfers/Uploads/UploadService.cs b/src/slskd/Transfers/Uploads/UploadService.cs index c72c96ee..35bb9468 100644 --- a/src/slskd/Transfers/Uploads/UploadService.cs +++ b/src/slskd/Transfers/Uploads/UploadService.cs @@ -45,6 +45,7 @@ namespace slskd.Transfers.Uploads using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; + using Microsoft.EntityFrameworkCore.Query; using Serilog; using slskd.Events; using slskd.Relay; @@ -111,9 +112,9 @@ namespace slskd.Transfers.Uploads UserUploadStatistics GetUserStatistics(string username, DateTime? utcNow = null); /// <summary> - /// Returns a list of all uploads matching the optional <paramref name="expression"/>. + /// Returns a list of all uploads matching the specified <paramref name="expression"/>. /// </summary> - /// <param name="expression">An optional expression used to match uploads.</param> + /// <param name="expression">An expression used to match uploads.</param> /// <param name="includeRemoved">A value indicating whether to include uploads that have been removed previously.</param> /// <returns>The list of uploads matching the specified expression, or all uploads if no expression is specified.</returns> List<Transfer> List(Expression<Func<Transfer, bool>> expression, bool includeRemoved); @@ -822,14 +823,26 @@ namespace slskd.Transfers.Uploads } /// <summary> - /// Returns a list of all uploads matching the optional <paramref name="expression"/>. + /// Returns a list of all uploads matching the specified <paramref name="expression"/>. /// </summary> - /// <param name="expression">An optional expression used to match uploads.</param> + /// <param name="expression">An expression used to match uploads.</param> /// <param name="includeRemoved">A value indicating whether to include uploads that have been removed previously.</param> /// <returns>The list of uploads matching the specified expression, or all uploads if no expression is specified.</returns> public List<Transfer> List(Expression<Func<Transfer, bool>> expression, bool includeRemoved) { expression ??= t => true; + + try + { + return Query(q => q.Where(expression), includeRemoved); + } + catch (Exception ex) + { + Log.Error(ex, "Failed to list uploads: {Message}", ex.Message); + throw; + } + } + /// <summary> /// Returns a list of all uploads matching the specified <paramref name="query"/>, projected to type <typeparamref name="TResult"/>. /// </summary> |
