From bd8fe8eb32dc6550d23bd2840b37797e7fc70c48 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 15 Oct 2023 15:29:20 -0500 Subject: move transfer retention options --- config/slskd.example.yml | 17 ++++++----- docs/config.md | 17 ++++++----- src/slskd/Application.cs | 12 ++++---- src/slskd/Core/Options.cs | 76 +++++++++++++++++++++++++++-------------------- 4 files changed, 68 insertions(+), 54 deletions(-) diff --git a/config/slskd.example.yml b/config/slskd.example.yml index daabc838..cc308e8d 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -108,14 +108,15 @@ # role: readonly # readonly, readwrite, administrator # cidr: 0.0.0.0/0,::/0 # retention: -# upload: -# succeeded: 1440 # 1 day -# errored: 30 -# cancelled: 5 -# download: -# succeeded: 1440 # 1 day -# errored: 20160 # 2 weeks -# cancelled: 5 +# transfers: +# upload: +# succeeded: 1440 # 1 day +# errored: 30 +# cancelled: 5 +# download: +# succeeded: 1440 # 1 day +# errored: 20160 # 2 weeks +# cancelled: 5 # files: # complete: 20160 # 2 weeks # incomplete: 43200 # 30 days diff --git a/docs/config.md b/docs/config.md index 2038d98a..6102c5c1 100644 --- a/docs/config.md +++ b/docs/config.md @@ -734,14 +734,15 @@ All retention periods are specified in minutes. #### **YAML** ```yaml retention: - upload: - succeeded: 1440 # 1 day - errored: 30 - cancelled: 5 - download: - succeeded: 1440 # 1 day - errored: 20160 # 2 weeks - cancelled: 5 + transfers: + upload: + succeeded: 1440 # 1 day + errored: 30 + cancelled: 5 + download: + succeeded: 1440 # 1 day + errored: 20160 # 2 weeks + cancelled: 5 files: complete: 20160 # 2 weeks incomplete: 43200 # 30 days diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 6d6ccd37..89ff6b27 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -821,13 +821,13 @@ namespace slskd try { - PruneUpload(options.Upload.Succeeded, TransferStates.Succeeded); - PruneUpload(options.Upload.Cancelled, TransferStates.Cancelled); - PruneUpload(options.Upload.Errored, TransferStates.Errored); + PruneUpload(options.Transfers.Upload.Succeeded, TransferStates.Succeeded); + PruneUpload(options.Transfers.Upload.Cancelled, TransferStates.Cancelled); + PruneUpload(options.Transfers.Upload.Errored, TransferStates.Errored); - PruneDownload(options.Download.Succeeded, TransferStates.Succeeded); - PruneDownload(options.Download.Cancelled, TransferStates.Cancelled); - PruneDownload(options.Download.Errored, TransferStates.Errored); + PruneDownload(options.Transfers.Download.Succeeded, TransferStates.Succeeded); + PruneDownload(options.Transfers.Download.Cancelled, TransferStates.Cancelled); + PruneDownload(options.Transfers.Download.Errored, TransferStates.Errored); } catch { diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 9d92bb95..2b9c3455 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -1060,22 +1060,16 @@ namespace slskd public class RetentionOptions { /// - /// Gets file retention options. - /// - [Validate] - public FileRetentionOptions Files { get; init; } = new FileRetentionOptions(); - - /// - /// Gets upload retention options. + /// Gets transfer retention options. /// [Validate] - public TransferRetentionOptions Upload { get; init; } = new TransferRetentionOptions(); + public TransferRetentionOptions Transfers { get; init; } = new TransferRetentionOptions(); /// - /// Gets download retention options. + /// Gets file retention options. /// [Validate] - public TransferRetentionOptions Download { get; init; } = new TransferRetentionOptions(); + public FileRetentionOptions Files { get; init; } = new FileRetentionOptions(); /// /// Gets the time to retain logs, in days. @@ -1084,45 +1078,63 @@ namespace slskd public int Logs { get; init; } = 180; /// - /// File retention options. + /// Transfer retention options. /// - public class FileRetentionOptions + public class TransferRetentionOptions { /// - /// Gets the time to retain completed files, in minutes. + /// Gets upload retention options. /// - [Range(30, maximum: int.MaxValue)] - public int? Complete { get; init; } = null; + [Validate] + public TransferTypeRetentionOptions Upload { get; init; } = new TransferTypeRetentionOptions(); /// - /// Gets the time to retain incomplete files, in minutes. + /// Gets download retention options. /// - [Range(30, maximum: int.MaxValue)] - public int? Incomplete { get; init; } = null; + [Validate] + public TransferTypeRetentionOptions Download { get; init; } = new TransferTypeRetentionOptions(); + + /// + /// Transfer retention options. + /// + public class TransferTypeRetentionOptions + { + /// + /// Gets the time to retain successful transfers, in minutes. + /// + [Range(5, maximum: int.MaxValue)] + public int? Succeeded { get; init; } = null; + + /// + /// Gets the time to retain errored transfers, in minutes. + /// + [Range(5, maximum: int.MaxValue)] + public int? Errored { get; init; } = null; + + /// + /// Gets the time to retain cancelled transfers, in minutes. + /// + [Range(5, maximum: int.MaxValue)] + public int? Cancelled { get; init; } = null; + } } /// - /// Transfer retention options. + /// File retention options. /// - public class TransferRetentionOptions + public class FileRetentionOptions { /// - /// Gets the time to retain successful transfers, in minutes. - /// - [Range(5, maximum: int.MaxValue)] - public int? Succeeded { get; init; } = null; - - /// - /// Gets the time to retain errored transfers, in minutes. + /// Gets the time to retain completed files, in minutes. /// - [Range(5, maximum: int.MaxValue)] - public int? Errored { get; init; } = null; + [Range(30, maximum: int.MaxValue)] + public int? Complete { get; init; } = null; /// - /// Gets the time to retain cancelled transfers, in minutes. + /// Gets the time to retain incomplete files, in minutes. /// - [Range(5, maximum: int.MaxValue)] - public int? Cancelled { get; init; } = null; + [Range(30, maximum: int.MaxValue)] + public int? Incomplete { get; init; } = null; } } -- cgit v1.2.3