diff options
| author | JP Dillingham <jp@dillingham.me> | 2023-10-15 15:39:28 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-15 15:39:28 -0500 |
| commit | f2c0f7658a95e4c6425eb455ef4d19f64fb841d8 (patch) | |
| tree | 46630f3e0ffb8ed6c5289dc37946ae5bf47b662e | |
| parent | 5986bcadc179e3e9a34152687b80210dcc65e366 (diff) | |
| parent | bd8fe8eb32dc6550d23bd2840b37797e7fc70c48 (diff) | |
| download | slskd-f2c0f7658a95e4c6425eb455ef4d19f64fb841d8.tar.gz | |
Merge pull request #980 from slskd/retention
Move transfer retention options
| -rw-r--r-- | config/slskd.example.yml | 17 | ||||
| -rw-r--r-- | docs/config.md | 17 | ||||
| -rw-r--r-- | src/slskd/Application.cs | 12 | ||||
| -rw-r--r-- | 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 { /// <summary> - /// Gets file retention options. - /// </summary> - [Validate] - public FileRetentionOptions Files { get; init; } = new FileRetentionOptions(); - - /// <summary> - /// Gets upload retention options. + /// Gets transfer retention options. /// </summary> [Validate] - public TransferRetentionOptions Upload { get; init; } = new TransferRetentionOptions(); + public TransferRetentionOptions Transfers { get; init; } = new TransferRetentionOptions(); /// <summary> - /// Gets download retention options. + /// Gets file retention options. /// </summary> [Validate] - public TransferRetentionOptions Download { get; init; } = new TransferRetentionOptions(); + public FileRetentionOptions Files { get; init; } = new FileRetentionOptions(); /// <summary> /// Gets the time to retain logs, in days. @@ -1084,45 +1078,63 @@ namespace slskd public int Logs { get; init; } = 180; /// <summary> - /// File retention options. + /// Transfer retention options. /// </summary> - public class FileRetentionOptions + public class TransferRetentionOptions { /// <summary> - /// Gets the time to retain completed files, in minutes. + /// Gets upload retention options. /// </summary> - [Range(30, maximum: int.MaxValue)] - public int? Complete { get; init; } = null; + [Validate] + public TransferTypeRetentionOptions Upload { get; init; } = new TransferTypeRetentionOptions(); /// <summary> - /// Gets the time to retain incomplete files, in minutes. + /// Gets download retention options. /// </summary> - [Range(30, maximum: int.MaxValue)] - public int? Incomplete { get; init; } = null; + [Validate] + public TransferTypeRetentionOptions Download { get; init; } = new TransferTypeRetentionOptions(); + + /// <summary> + /// Transfer retention options. + /// </summary> + public class TransferTypeRetentionOptions + { + /// <summary> + /// Gets the time to retain successful transfers, in minutes. + /// </summary> + [Range(5, maximum: int.MaxValue)] + public int? Succeeded { get; init; } = null; + + /// <summary> + /// Gets the time to retain errored transfers, in minutes. + /// </summary> + [Range(5, maximum: int.MaxValue)] + public int? Errored { get; init; } = null; + + /// <summary> + /// Gets the time to retain cancelled transfers, in minutes. + /// </summary> + [Range(5, maximum: int.MaxValue)] + public int? Cancelled { get; init; } = null; + } } /// <summary> - /// Transfer retention options. + /// File retention options. /// </summary> - public class TransferRetentionOptions + public class FileRetentionOptions { /// <summary> - /// Gets the time to retain successful transfers, in minutes. - /// </summary> - [Range(5, maximum: int.MaxValue)] - public int? Succeeded { get; init; } = null; - - /// <summary> - /// Gets the time to retain errored transfers, in minutes. + /// Gets the time to retain completed files, in minutes. /// </summary> - [Range(5, maximum: int.MaxValue)] - public int? Errored { get; init; } = null; + [Range(30, maximum: int.MaxValue)] + public int? Complete { get; init; } = null; /// <summary> - /// Gets the time to retain cancelled transfers, in minutes. + /// Gets the time to retain incomplete files, in minutes. /// </summary> - [Range(5, maximum: int.MaxValue)] - public int? Cancelled { get; init; } = null; + [Range(30, maximum: int.MaxValue)] + public int? Incomplete { get; init; } = null; } } |
