From 915bcc9544575f60ab918ee7b127ada431d4ffc6 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 16 Dec 2024 18:11:38 -0600 Subject: add search retention options --- config/slskd.example.yml | 11 ++++++----- src/slskd/Core/Options.cs | 6 ++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/config/slskd.example.yml b/config/slskd.example.yml index be2a0c6e..1993de22 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -156,18 +156,19 @@ # role: readonly # readonly, readwrite, administrator # cidr: 0.0.0.0/0,::/0 # retention: +# searches: 10080 # 7 days, in minutes # transfers: # upload: -# succeeded: 1440 # 1 day +# succeeded: 1440 # 1 day, in minutes # errored: 30 # cancelled: 5 # download: -# succeeded: 1440 # 1 day -# errored: 20160 # 2 weeks +# succeeded: 1440 # 1 day, in minutes +# errored: 20160 # 2 weeks, in minutes # cancelled: 5 # files: -# complete: 20160 # 2 weeks -# incomplete: 43200 # 30 days +# complete: 20160 # 2 weeks, in minutes +# incomplete: 43200 # 30 days, in minutes # logs: 180 # days # logger: # disk: false diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index e5f16b1e..8c705e85 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -1311,6 +1311,12 @@ namespace slskd /// public class RetentionOptions { + /// + /// Gets the time to retain searches, in minutes. + /// + [Range(60, maximum: int.MaxValue)] + public int? Search { get; init; } = null; + /// /// Gets transfer retention options. /// -- cgit v1.2.3 From d16cd958001f4c9474a2bd511fb3b40a4d7c7daf Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 16 Dec 2024 18:12:07 -0600 Subject: consolidate I/SearchService --- src/slskd/Search/ISearchService.cs | 71 -------------------------------------- src/slskd/Search/SearchService.cs | 56 +++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 72 deletions(-) delete mode 100644 src/slskd/Search/ISearchService.cs diff --git a/src/slskd/Search/ISearchService.cs b/src/slskd/Search/ISearchService.cs deleted file mode 100644 index 097e23de..00000000 --- a/src/slskd/Search/ISearchService.cs +++ /dev/null @@ -1,71 +0,0 @@ -// -// Copyright (c) slskd Team. All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published -// by the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see https://www.gnu.org/licenses/. -// - -namespace slskd.Search -{ - using System; - using System.Collections.Generic; - using System.Linq.Expressions; - using System.Threading.Tasks; - using Soulseek; - - /// - /// Handles the lifecycle and persistence of searches. - /// - public interface ISearchService - { - /// - /// Deletes the specified search. - /// - /// The search to delete. - /// The operation context. - Task DeleteAsync(Search search); - - /// - /// Finds a single search matching the specified . - /// - /// The expression to use to match searches. - /// A value indicating whether to include search responses in the result. - /// The found search, or default if not found. - /// Thrown when an expression is not supplied. - Task FindAsync(Expression> expression, bool includeResponses = false); - - /// - /// Returns a list of all completed and in-progress searches, with responses omitted, matching the optional . - /// - /// An optional expression used to match searches. - /// The list of searches matching the specified expression, or all searches if no expression is specified. - Task> ListAsync(Expression> expression = null); - - /// - /// Performs a search for the specified and . - /// - /// A unique identifier for the search. - /// The search query. - /// The search scope. - /// Search options. - /// The completed search. - Task StartAsync(Guid id, SearchQuery query, SearchScope scope, SearchOptions options = null); - - /// - /// Cancels the search matching the specified , if it is in progress. - /// - /// The unique identifier for the search. - /// A value indicating whether the search was successfully cancelled. - bool TryCancel(Guid id); - } -} \ No newline at end of file diff --git a/src/slskd/Search/SearchService.cs b/src/slskd/Search/SearchService.cs index 3d2e2750..ed661b1f 100644 --- a/src/slskd/Search/SearchService.cs +++ b/src/slskd/Search/SearchService.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) slskd Team. All rights reserved. // // This program is free software: you can redistribute it and/or modify @@ -36,6 +36,60 @@ namespace slskd.Search using SearchScope = Soulseek.SearchScope; using SearchStates = Soulseek.SearchStates; + /// + /// Handles the lifecycle and persistence of searches. + /// + public interface ISearchService + { + /// + /// Deletes the specified search. + /// + /// The search to delete. + /// The operation context. + Task DeleteAsync(Search search); + + /// + /// Finds a single search matching the specified . + /// + /// The expression to use to match searches. + /// A value indicating whether to include search responses in the result. + /// The found search, or default if not found. + /// Thrown when an expression is not supplied. + Task FindAsync(Expression> expression, bool includeResponses = false); + + /// + /// Returns a list of all completed and in-progress searches, with responses omitted, matching the optional . + /// + /// An optional expression used to match searches. + /// The list of searches matching the specified expression, or all searches if no expression is specified. + Task> ListAsync(Expression> expression = null); + + /// + /// Performs a search for the specified and . + /// + /// A unique identifier for the search. + /// The search query. + /// The search scope. + /// Search options. + /// The completed search. + Task StartAsync(Guid id, SearchQuery query, SearchScope scope, SearchOptions options = null); + + /// + /// Cancels the search matching the specified , if it is in progress. + /// + /// The unique identifier for the search. + /// A value indicating whether the search was successfully cancelled. + bool TryCancel(Guid id); + + /// + /// Removes searches older than the specified . + /// + /// The age after which records are eligible for pruning, in minutes. + /// An optional, additional state by which records are filtered for pruning. + /// The number of pruned records. + int Prune(int age, SearchStates state = SearchStates.Completed); + } + /// /// Handles the lifecycle and persistence of searches. /// -- cgit v1.2.3 From 71d2376683de76ee20129d151dccfb70b59ba5fd Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 16 Dec 2024 18:12:22 -0600 Subject: fix erroneous docs --- src/slskd/Transfers/Uploads/UploadService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/slskd/Transfers/Uploads/UploadService.cs b/src/slskd/Transfers/Uploads/UploadService.cs index ea9d2a5c..362479e4 100644 --- a/src/slskd/Transfers/Uploads/UploadService.cs +++ b/src/slskd/Transfers/Uploads/UploadService.cs @@ -93,7 +93,7 @@ namespace slskd.Transfers.Uploads /// /// Removes uploads older than the specified . /// - /// The age after which uploads are eligible for pruning, in hours. + /// The age after which uploads are eligible for pruning, in minutes. /// An optional, additional state by which uploads are filtered for pruning. /// The number of pruned uploads. int Prune(int age, TransferStates state = TransferStates.Completed); @@ -521,7 +521,7 @@ namespace slskd.Transfers.Uploads /// /// Removes uploads older than the specified . /// - /// The age after which uploads are eligible for pruning, in hours. + /// The age after which uploads are eligible for pruning, in minutes. /// An optional, additional state by which uploads are filtered for pruning. /// The number of pruned uploads. public int Prune(int age, TransferStates state = TransferStates.Completed) -- cgit v1.2.3 From f309223b5f30f21e3f17ed5e229c8ea40eb92369 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 16 Dec 2024 18:13:52 -0600 Subject: wire up SearchService and prune every 60 minutes --- src/slskd/Application.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index b0372422..38d25477 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -96,6 +96,7 @@ namespace slskd IUserService userService, IMessagingService messagingService, IShareService shareService, + ISearchService searchService, IPushbulletService pushbulletService, IRelayService relayService, EventService eventService, @@ -146,6 +147,8 @@ namespace slskd Shares = shareService; Shares.StateMonitor.OnChange(state => ShareState_OnChange(state)); + Search = searchService; + Events = eventService; Transfers = transferService; @@ -227,6 +230,7 @@ namespace slskd private IHubContext LogHub { get; set; } private IUserService Users { get; set; } private IShareService Shares { get; set; } + private ISearchService Search { get; set; } private EventService Events { get; } private IRelayService Relay { get; set; } private IMemoryCache Cache { get; set; } = new MemoryCache(new MemoryCacheOptions()); @@ -1014,6 +1018,7 @@ namespace slskd private void Clock_EveryHour(object sender, ClockEventArgs e) { _ = Task.Run(() => MaybeRescanShares()); + _ = Task.Run(() => PruneSearches()); } private async Task MaybeRescanShares() @@ -1142,6 +1147,16 @@ namespace slskd } } + private void PruneSearches() + { + var age = OptionsMonitor.CurrentValue.Retention.Search; + + if (age.HasValue) + { + Search.Prune(age.Value); + } + } + private void Client_ExcludedSearchPhrasesReceived(object sender, IReadOnlyCollection e) { Log.Debug("Excluded search phrases: {Phrases}", string.Join(", ", e)); -- cgit v1.2.3 From 335e9ced13a9e4eb236438b01a24e9968a964452 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 16 Dec 2024 18:33:43 -0600 Subject: clarify HasFlag() warning --- src/slskd/Transfers/Uploads/UploadService.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/slskd/Transfers/Uploads/UploadService.cs b/src/slskd/Transfers/Uploads/UploadService.cs index 362479e4..da7cfdcd 100644 --- a/src/slskd/Transfers/Uploads/UploadService.cs +++ b/src/slskd/Transfers/Uploads/UploadService.cs @@ -541,7 +541,11 @@ namespace slskd.Transfers.Uploads .Where(t => t.Direction == TransferDirection.Upload) .Where(t => !t.Removed) .Where(t => t.EndedAt.HasValue && t.EndedAt.Value < cutoffDateTime) - .Where(t => t.State == state) // https://github.com/dotnet/efcore/issues/20094 + + // note: don't try HasFlag() here: https://github.com/dotnet/efcore/issues/20094 + // this won't work because the state is stored as a comma separated string (which we've done deliberately) + // and EF won't do the necessary work to generate the required SQL + .Where(t => t.State == state) .ToList(); foreach (var tx in expired) -- cgit v1.2.3 From 1a0ab325c75e0f89a1afd6227402b431aeb3db32 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 16 Dec 2024 18:35:15 -0600 Subject: implement search prune --- src/slskd/Search/SearchService.cs | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/slskd/Search/SearchService.cs b/src/slskd/Search/SearchService.cs index ed661b1f..68f3e559 100644 --- a/src/slskd/Search/SearchService.cs +++ b/src/slskd/Search/SearchService.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) slskd Team. All rights reserved. // // This program is free software: you can redistribute it and/or modify @@ -85,9 +85,8 @@ namespace slskd.Search /// Removes searches older than the specified . /// /// The age after which records are eligible for pruning, in minutes. - /// An optional, additional state by which records are filtered for pruning. /// The number of pruned records. - int Prune(int age, SearchStates state = SearchStates.Completed); + int Prune(int age); } /// @@ -310,5 +309,39 @@ namespace slskd.Search return false; } + + /// + /// Removes searches older than the specified . + /// + /// The age after which searches are eligible for pruning, in minutes. + /// The number of pruned records. + public int Prune(int age) + { + try + { + using var context = ContextFactory.CreateDbContext(); + + var cutoffDateTime = DateTime.UtcNow.AddMinutes(-age); + + // unlike other pruning operations, we don't care about state, since there's a 60 minute minimum + // and searches are guaranteed to be at least 60 minutes old by the time they can be pruned, they will + // be completed unless someone applied some rather dumb settings + var expired = context.Searches + .Where(s => !s.EndedAt.HasValue && s.EndedAt.Value < cutoffDateTime) + .ToList(); + + // also unlike other contexts, we don't soft delete searches + // there's no value in keeping them and because we store the responses inline, they take up a lot of space + context.Searches.RemoveRange(expired); + context.SaveChanges(); + + return expired.Count; + } + catch (Exception ex) + { + Log.Error(ex, "Failed to prune searches: {Message}", ex.Message); + throw; + } + } } } \ No newline at end of file -- cgit v1.2.3 From 29a10ae1952dc0beb25703898f8157b8f4ed4302 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 16 Dec 2024 18:35:24 -0600 Subject: log search pruning --- src/slskd/Application.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 38d25477..d7b9ba34 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -1153,7 +1153,15 @@ namespace slskd if (age.HasValue) { - Search.Prune(age.Value); + try + { + var pruned = Search.Prune(age.Value); + Log.Debug("Pruned {Count} search records", pruned); + } + catch + { + Log.Error("Encountered one or more errors while pruning searches"); + } } } -- cgit v1.2.3 From 7b0fb41b43fe7b97316fc7112cc9b6d0fc7f628d Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 17 Dec 2024 13:47:06 -0600 Subject: add log override for EF --- src/slskd/Program.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index b302cc8c..f2c61b14 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -1024,6 +1024,7 @@ namespace slskd .MinimumLevel.Override("System.Net.Http.HttpClient", OptionsAtStartup.Debug ? LogEventLevel.Warning : LogEventLevel.Fatal) .MinimumLevel.Override("slskd.Authentication.PassthroughAuthenticationHandler", LogEventLevel.Warning) .MinimumLevel.Override("slskd.Authentication.ApiKeyAuthenticationHandler", LogEventLevel.Warning) + .MinimumLevel.Override("Microsoft.EntityFrameworkCore.Database.Command", LogEventLevel.Warning) // bump this down to Information to show SQL .Enrich.WithProperty("InstanceName", OptionsAtStartup.InstanceName) .Enrich.WithProperty("InvocationId", InvocationId) .Enrich.WithProperty("ProcessId", ProcessId) -- cgit v1.2.3 From 20bcd7e388a4dc14f95579f08198e82a1c6ac35c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 17 Dec 2024 14:27:19 -0600 Subject: exclude responses when fetching to delete --- src/slskd/Search/API/Controllers/SearchesController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slskd/Search/API/Controllers/SearchesController.cs b/src/slskd/Search/API/Controllers/SearchesController.cs index 56c5f533..d6d96bbe 100644 --- a/src/slskd/Search/API/Controllers/SearchesController.cs +++ b/src/slskd/Search/API/Controllers/SearchesController.cs @@ -210,7 +210,7 @@ namespace slskd.Search.API return Forbid(); } - var search = await Searches.FindAsync(search => search.Id == id, includeResponses: true); + var search = await Searches.FindAsync(search => search.Id == id, includeResponses: false); if (search == default) { -- cgit v1.2.3 From 57d560e91247dc27a9b70bed8f4acafcbb9e03b1 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 17 Dec 2024 14:27:41 -0600 Subject: explicitly exclude search responses when broadcasting --- src/slskd/Search/API/Hubs/SearchHub.cs | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/slskd/Search/API/Hubs/SearchHub.cs b/src/slskd/Search/API/Hubs/SearchHub.cs index b1fbf725..b4d2b6f0 100644 --- a/src/slskd/Search/API/Hubs/SearchHub.cs +++ b/src/slskd/Search/API/Hubs/SearchHub.cs @@ -39,16 +39,19 @@ namespace slskd.Search.API /// /// Broadcast an update for a search. /// + /// + /// Responses are removed prior to sending. + /// /// The hub. /// The search to broadcast. /// The operation context. public static Task BroadcastUpdateAsync(this IHubContext hub, Search search) { - return hub.Clients.All.SendAsync(SearchHubMethods.Update, search); + return hub.Clients.All.SendAsync(SearchHubMethods.Update, search with { Responses = null }); } /// - /// Broadcast the present application options. + /// Broadcast a newly recieved search response. /// /// The hub. /// The ID of the search associated with the response. @@ -59,14 +62,32 @@ namespace slskd.Search.API return hub.Clients.All.SendAsync(SearchHubMethods.Response, new { searchId, response }); } + /// + /// Broadcast the creation of a new search. + /// + /// + /// Responses are removed prior to sending. + /// + /// The hub. + /// The search to broadcast. + /// The operation context. public static Task BroadcastCreateAsync(this IHubContext hub, Search search) { - return hub.Clients.All.SendAsync(SearchHubMethods.Create, search); + return hub.Clients.All.SendAsync(SearchHubMethods.Create, search with { Responses = null }); } + /// + /// Broadcast the deletion of a search. + /// + /// + /// Responses are removed prior to sending. + /// + /// The hub. + /// The search to broadcast. + /// The operation context. public static Task BroadcastDeleteAsync(this IHubContext hub, Search search) { - return hub.Clients.All.SendAsync(SearchHubMethods.Delete, search); + return hub.Clients.All.SendAsync(SearchHubMethods.Delete, search with { Responses = null }); } } -- cgit v1.2.3 From b2ef8e528888facc375e228bf87fea08a772e11f Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 17 Dec 2024 14:27:56 -0600 Subject: make Search a record --- src/slskd/Search/Types/Search.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slskd/Search/Types/Search.cs b/src/slskd/Search/Types/Search.cs index 52f97075..577faf14 100644 --- a/src/slskd/Search/Types/Search.cs +++ b/src/slskd/Search/Types/Search.cs @@ -25,7 +25,7 @@ namespace slskd.Search using System.Text.Json.Serialization; using Soulseek; - public class Search + public record Search { public DateTime? EndedAt { get; set; } public int FileCount { get; set; } -- cgit v1.2.3 From a2225b593955232418de262929e53a49136b6293 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 17 Dec 2024 14:31:13 -0600 Subject: fix bug in search selection, use internal DeleteAsync so deletes are broadcast --- src/slskd/Search/SearchService.cs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/slskd/Search/SearchService.cs b/src/slskd/Search/SearchService.cs index 68f3e559..809647b2 100644 --- a/src/slskd/Search/SearchService.cs +++ b/src/slskd/Search/SearchService.cs @@ -86,7 +86,7 @@ namespace slskd.Search /// /// The age after which records are eligible for pruning, in minutes. /// The number of pruned records. - int Prune(int age); + Task PruneAsync(int age); } /// @@ -247,6 +247,8 @@ namespace slskd.Search search.FileCount = args.Search.FileCount; search.LockedFileCount = args.Search.LockedFileCount; + // note that we're not actually doing anything with the response here, that's happening in the + // response handler. we're only updating counts here. SearchHub.BroadcastUpdateAsync(search); UpdateAndSaveChanges(search); })); @@ -278,9 +280,9 @@ namespace slskd.Search UpdateAndSaveChanges(search); - // zero responses before broadcasting - search.Responses = Enumerable.Empty(); - await SearchHub.BroadcastUpdateAsync(search); + // zero responses before broadcasting, as we don't want to blast this + // data out over the SignalR socket + await SearchHub.BroadcastUpdateAsync(search with { Responses = [] }); } catch (Exception ex) { @@ -315,7 +317,7 @@ namespace slskd.Search /// /// The age after which searches are eligible for pruning, in minutes. /// The number of pruned records. - public int Prune(int age) + public async Task PruneAsync(int age) { try { @@ -327,13 +329,16 @@ namespace slskd.Search // and searches are guaranteed to be at least 60 minutes old by the time they can be pruned, they will // be completed unless someone applied some rather dumb settings var expired = context.Searches - .Where(s => !s.EndedAt.HasValue && s.EndedAt.Value < cutoffDateTime) + .Where(s => s.EndedAt.HasValue && s.EndedAt.Value < cutoffDateTime) + .WithoutResponses() .ToList(); - // also unlike other contexts, we don't soft delete searches - // there's no value in keeping them and because we store the responses inline, they take up a lot of space - context.Searches.RemoveRange(expired); - context.SaveChanges(); + // defer the deletion to DeleteAsync() so that SignalR broadcasting works properly and the UI + // is updated in real time + foreach (var search in expired) + { + await DeleteAsync(search); + } return expired.Count; } -- cgit v1.2.3 From a58f1484980b1e970c5ba789d8201e6160e507bb Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 17 Dec 2024 14:47:58 -0600 Subject: prune searches every 5 minutes --- src/slskd/Application.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index d7b9ba34..c15f741b 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -1007,6 +1007,7 @@ namespace slskd private void Clock_EveryFiveMinutes(object sender, ClockEventArgs e) { + _ = Task.Run(() => PruneSearches()); _ = Task.Run(() => PruneTransfers()); } @@ -1018,7 +1019,6 @@ namespace slskd private void Clock_EveryHour(object sender, ClockEventArgs e) { _ = Task.Run(() => MaybeRescanShares()); - _ = Task.Run(() => PruneSearches()); } private async Task MaybeRescanShares() @@ -1147,7 +1147,7 @@ namespace slskd } } - private void PruneSearches() + private async Task PruneSearches() { var age = OptionsMonitor.CurrentValue.Retention.Search; @@ -1155,7 +1155,7 @@ namespace slskd { try { - var pruned = Search.Prune(age.Value); + var pruned = await Search.PruneAsync(age.Value); Log.Debug("Pruned {Count} search records", pruned); } catch -- cgit v1.2.3 From aa079e354e97fbbd1b865dd4687c55851a582a6c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 17 Dec 2024 14:48:09 -0600 Subject: set minimum of search prune to 5 minutes --- src/slskd/Core/Options.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 8c705e85..a7fb26c4 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -1314,7 +1314,7 @@ namespace slskd /// /// Gets the time to retain searches, in minutes. /// - [Range(60, maximum: int.MaxValue)] + [Range(5, maximum: int.MaxValue)] public int? Search { get; init; } = null; /// -- cgit v1.2.3 From 050495ddadd89638f04fcebb133197e6ec341d8e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 17 Dec 2024 15:00:22 -0600 Subject: remove noisy log --- src/slskd/Application.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index c15f741b..bc8046cc 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -1156,8 +1156,6 @@ namespace slskd try { var pruned = await Search.PruneAsync(age.Value); - Log.Debug("Pruned {Count} search records", pruned); - } catch { Log.Error("Encountered one or more errors while pruning searches"); -- cgit v1.2.3 From 4786b7d95b9a6b4f597e861e8ee95ac24d0b6c11 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 17 Dec 2024 15:00:44 -0600 Subject: missing brace --- src/slskd/Application.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index bc8046cc..05f62902 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -1156,6 +1156,7 @@ namespace slskd try { var pruned = await Search.PruneAsync(age.Value); + } catch { Log.Error("Encountered one or more errors while pruning searches"); -- cgit v1.2.3 From a1ddaccf2fa3e6c86ee3f89d2b62dd210b72f9e6 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 17 Dec 2024 16:03:17 -0600 Subject: typo --- src/slskd/Search/API/Hubs/SearchHub.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slskd/Search/API/Hubs/SearchHub.cs b/src/slskd/Search/API/Hubs/SearchHub.cs index b4d2b6f0..e1cfb4b5 100644 --- a/src/slskd/Search/API/Hubs/SearchHub.cs +++ b/src/slskd/Search/API/Hubs/SearchHub.cs @@ -51,7 +51,7 @@ namespace slskd.Search.API } /// - /// Broadcast a newly recieved search response. + /// Broadcast a newly received search response. /// /// The hub. /// The ID of the search associated with the response. -- cgit v1.2.3 From 57704f7a402bd779c74b42b460c6bb0d206cbe0c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 17 Dec 2024 16:30:06 -0600 Subject: docs --- docs/config.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/config.md b/docs/config.md index 9d17974f..e83fc1a9 100644 --- a/docs/config.md +++ b/docs/config.md @@ -895,17 +895,20 @@ filters: By default, most things created by the application are retained indefinitely; they have to be removed manually by the user. Users can optionally configure certain things to be removed or deleted automatically after a period of time. +Completed searches can be configured to be removed from the UI and 'hard' deleted from the database. It's a good idea to set this to something relatively short, as old searches have diminishing value as they age and the records contain a lot of data. + Transfers can be configured to be removed from the UI after they are complete by specifying retention periods for uploads and downloads separately, and by transfer state; succeeded, errored, and cancelled. Files (on disk) can be configured to be deleted after the age of their last access time exceeds the configured time. Completed and incomplete files can be configured separately. Application logs are removed after 180 days by default, but this can be configured as well. -All retention periods are specified in minutes. +All retention periods are specified in minutes, with the exception of `logs`, which is in days. #### **YAML** ```yaml retention: + search: 1440 # 1 day transfers: upload: succeeded: 1440 # 1 day -- cgit v1.2.3