aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2023-09-17 16:46:17 -0500
committerJP Dillingham <jp@dillingham.me>2023-09-17 16:46:17 -0500
commitfe96fc98ef6f618f362da57114117fd59cb11508 (patch)
treee6d6c38fbd5c0fa500bfe9dc3bd6dd5808670ea9 /src
parent98536d94108044b709658895782ba25d5693825b (diff)
downloadslskd-fe96fc98ef6f618f362da57114117fd59cb11508.tar.gz
update implementation
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Application.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index 2720375f..7002da24 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -180,6 +180,7 @@ namespace slskd
Clock.EveryMinute += Clock_EveryMinute;
Clock.EveryFiveMinutes += Clock_EveryFiveMinutes;
+ Clock.EveryThirtyMinutes += Clock_EveryThirtyMinutes;
Clock.EveryHour += Clock_EveryHour;
}
@@ -726,12 +727,51 @@ namespace slskd
private void Clock_EveryFiveMinutes(object sender, EventArgs e)
{
+ PruneTransfers();
+ }
+ private void Clock_EveryThirtyMinutes(object sender, EventArgs e)
+ {
}
private void Clock_EveryHour(object sender, EventArgs e)
{
+ }
+
+ private void PruneTransfers()
+ {
+ var options = OptionsMonitor.CurrentValue.Retention;
+ void PruneUpload(int? age, TransferStates state)
+ {
+ if (age.HasValue)
+ {
+ Transfers.Uploads.Prune(age.Value, TransferStates.Completed | state);
+ }
+ }
+
+ void PruneDownload(int? age, TransferStates state)
+ {
+ if (age.HasValue)
+ {
+ Transfers.Downloads.Prune(age.Value, TransferStates.Completed | state);
+ }
+ }
+
+ try
+ {
+ PruneUpload(options.Upload.Succeeded, TransferStates.Succeeded);
+ PruneUpload(options.Upload.Cancelled, TransferStates.Cancelled);
+ PruneUpload(options.Upload.Errored, TransferStates.Errored);
+
+ PruneDownload(options.Download.Succeeded, TransferStates.Succeeded);
+ PruneDownload(options.Download.Cancelled, TransferStates.Cancelled);
+ PruneDownload(options.Download.Errored, TransferStates.Errored);
+ }
+ catch
+ {
+ Log.Error("Encountered one or more errors while pruning transfers");
+ }
}
private void Client_TransferProgressUpdated(object sender, TransferProgressUpdatedEventArgs args)