From cf5a29422198e4defc3820edf8b160f9bcd00857 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 16 Sep 2023 22:54:16 -0500 Subject: add retention options --- src/slskd/Core/Options.cs | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/slskd/Core/Options.cs') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 2ee21733..b2c85146 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -253,6 +253,12 @@ namespace slskd [Validate] public WebOptions Web { get; init; } = new WebOptions(); + /// + /// Gets retention options. + /// + [Validate] + public RetentionOptions Retention { get; init; } = new RetentionOptions(); + /// /// Gets logger options. /// @@ -1048,6 +1054,48 @@ namespace slskd public string Loki { get; init; } = null; } + /// + /// Retention options. + /// + public class RetentionOptions + { + /// + /// Gets upload retention options. + /// + [Validate] + public TransferRetentionOptions Upload { get; init; } = new TransferRetentionOptions(); + + /// + /// Gets download retention options. + /// + [Validate] + public TransferRetentionOptions Download { get; init; } = new TransferRetentionOptions(); + + /// + /// Transfer retention options. + /// + public class TransferRetentionOptions + { + /// + /// Gets the time to retain successful transfers, in minutes. + /// + [Range(60, maximum: int.MaxValue)] + public int Succeeded { get; init; } = int.MaxValue; + + /// + /// Gets the time to retain errored transfers, in minutes. + /// + [Range(60, maximum: int.MaxValue)] + public int Errored { get; init; } = int.MaxValue; + + /// + /// Gets the time to retain cancelled transfers, in minutes. + /// + [Range(60, maximum: int.MaxValue)] + public int Cancelled { get; init; } = int.MaxValue; + } + } + /// /// Metrics options. /// -- cgit v1.2.3 From 5966f7fe0245110591cbf5634efcb301712763a8 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 16 Sep 2023 22:56:48 -0500 Subject: specify retention in hours --- src/slskd/Core/Options.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/slskd/Core/Options.cs') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index b2c85146..7e21865f 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -1077,21 +1077,21 @@ namespace slskd public class TransferRetentionOptions { /// - /// Gets the time to retain successful transfers, in minutes. + /// Gets the time to retain successful transfers, in hours. /// - [Range(60, maximum: int.MaxValue)] + [Range(1, maximum: int.MaxValue)] public int Succeeded { get; init; } = int.MaxValue; /// - /// Gets the time to retain errored transfers, in minutes. + /// Gets the time to retain errored transfers, in hours. /// - [Range(60, maximum: int.MaxValue)] + [Range(1, maximum: int.MaxValue)] public int Errored { get; init; } = int.MaxValue; /// - /// Gets the time to retain cancelled transfers, in minutes. + /// Gets the time to retain cancelled transfers, in hours. /// - [Range(60, maximum: int.MaxValue)] + [Range(1, maximum: int.MaxValue)] public int Cancelled { get; init; } = int.MaxValue; } } -- cgit v1.2.3 From 98536d94108044b709658895782ba25d5693825b Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 17 Sep 2023 16:40:58 -0500 Subject: make retention options nullable, and in minutes --- config/slskd.example.yml | 12 ++++++------ src/slskd/Core/Options.cs | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src/slskd/Core/Options.cs') diff --git a/config/slskd.example.yml b/config/slskd.example.yml index 5b7ea7ae..2c22d020 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -109,13 +109,13 @@ # cidr: 0.0.0.0/0,::/0 # retention: # upload: -# succeeded: 2147483647 -# errored: 2147483647 -# cancelled: 2147483647 +# succeeded: 1440 # 1 day +# errored: 30 +# cancelled: 5 # download: -# succeeded: 2147483647 -# errored: 2147483647 -# cancelled: 2147483647 +# succeeded: 1440 # 1 day +# errored: 20160 # 2 weeks +# cancelled: 5 # logger: # loki: ~ # metrics: diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 7e21865f..30297cac 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -1077,22 +1077,22 @@ namespace slskd public class TransferRetentionOptions { /// - /// Gets the time to retain successful transfers, in hours. + /// Gets the time to retain successful transfers, in minutes. /// - [Range(1, maximum: int.MaxValue)] - public int Succeeded { get; init; } = int.MaxValue; + [Range(5, maximum: int.MaxValue)] + public int? Succeeded { get; init; } = null; /// - /// Gets the time to retain errored transfers, in hours. + /// Gets the time to retain errored transfers, in minutes. /// - [Range(1, maximum: int.MaxValue)] - public int Errored { get; init; } = int.MaxValue; + [Range(5, maximum: int.MaxValue)] + public int? Errored { get; init; } = null; /// - /// Gets the time to retain cancelled transfers, in hours. + /// Gets the time to retain cancelled transfers, in minutes. /// - [Range(1, maximum: int.MaxValue)] - public int Cancelled { get; init; } = int.MaxValue; + [Range(5, maximum: int.MaxValue)] + public int? Cancelled { get; init; } = null; } } -- cgit v1.2.3