From 453ac03bf30d4581477065d3f317dfd8fc50ed7b Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 2 Sep 2024 18:24:05 -0500 Subject: add retention option for events --- src/slskd/Core/Options.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/slskd/Core/Options.cs') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index cad58817..17c017f7 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -1322,6 +1322,12 @@ namespace slskd [Validate] public FileRetentionOptions Files { get; init; } = new FileRetentionOptions(); + /// + /// Gets the time to retain events, in days. + /// + [Range(1, maximum: int.MaxValue)] + public int Events { get; init; } = 30; + /// /// Gets the time to retain logs, in days. /// -- cgit v1.2.3 From 0a2c2db6c0a8f2a8325f128b314894e4db8cd369 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 2 Sep 2024 18:33:10 -0500 Subject: newlines --- src/slskd/Application.cs | 4 ++-- src/slskd/Core/Options.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/slskd/Core/Options.cs') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 18231ec1..a3d86034 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) slskd Team. All rights reserved. // // This program is free software: you can redistribute it and/or modify @@ -1650,4 +1650,4 @@ namespace slskd } } } -} +} \ No newline at end of file diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 17c017f7..97b596d0 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -2221,4 +2221,4 @@ namespace slskd } } } -} +} \ No newline at end of file -- cgit v1.2.3 From 1eb7649c460518bbedae2bc25fae120b9faf8157 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 15 Sep 2024 17:47:04 -0500 Subject: don't prune events (yet?) --- config/slskd.example.yml | 1 - src/slskd/Application.cs | 1 - src/slskd/Core/Options.cs | 6 ------ src/slskd/Events/EventService.cs | 29 ----------------------------- 4 files changed, 37 deletions(-) (limited to 'src/slskd/Core/Options.cs') diff --git a/config/slskd.example.yml b/config/slskd.example.yml index d4f99b21..4b4f0996 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -168,7 +168,6 @@ # files: # complete: 20160 # 2 weeks # incomplete: 43200 # 30 days -# events: 30 # days # logs: 180 # days # logger: # disk: false diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 1d13f73c..d441160e 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -1013,7 +1013,6 @@ namespace slskd private void Clock_EveryHour(object sender, ClockEventArgs e) { - _ = Task.Run(() => Events.Prune(ageInDays: Options.Retention.Events)); _ = Task.Run(() => MaybeRescanShares()); } diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 97b596d0..0f86ff62 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -1322,12 +1322,6 @@ namespace slskd [Validate] public FileRetentionOptions Files { get; init; } = new FileRetentionOptions(); - /// - /// Gets the time to retain events, in days. - /// - [Range(1, maximum: int.MaxValue)] - public int Events { get; init; } = 30; - /// /// Gets the time to retain logs, in days. /// diff --git a/src/slskd/Events/EventService.cs b/src/slskd/Events/EventService.cs index 188d5895..85f82238 100644 --- a/src/slskd/Events/EventService.cs +++ b/src/slskd/Events/EventService.cs @@ -66,33 +66,4 @@ public class EventService throw; } } - - /// - /// Removes event records older than the specified . - /// - /// The age after which event records are eligible for pruning, in days. - /// The number of pruned event records. - public virtual int Prune(int ageInDays) - { - try - { - using var context = ContextFactory.CreateDbContext(); - - var cutoffDateTime = DateTime.UtcNow.AddDays(-ageInDays); - - var pruned = context.Events.Where(e => e.Timestamp < cutoffDateTime).ExecuteDelete(); - - if (pruned > 0) - { - Log.Debug("Pruned {Count} expired events", pruned); - } - - return pruned; - } - catch (Exception ex) - { - Log.Error(ex, "Failed to prune events: {Message}", ex.Message); - throw; - } - } } \ No newline at end of file -- cgit v1.2.3