From 6a2533aa3b79fcc7ab4e5536a24bd0a92dcf1f3c Mon Sep 17 00:00:00 2001 From: Roger Far Date: Sun, 6 Feb 2022 16:03:12 -0700 Subject: [PATCH] Added lifetime setting to automatically expire torrents after a certain amount of time. --- CHANGELOG.md | 1 + .../add-new-torrent.component.html | 12 +- .../add-new-torrent.component.ts | 1 + client/src/app/models/torrent.model.ts | 1 + .../src/app/settings/settings.component.html | 13 +- client/src/app/settings/settings.component.ts | 6 + client/src/app/torrent/torrent.component.html | 19 +- client/src/app/torrent/torrent.component.ts | 3 + server/RdtClient.Data/Data/DataContext.cs | 6 + server/RdtClient.Data/Data/SettingData.cs | 1 + server/RdtClient.Data/Data/TorrentData.cs | 4 +- ...06225658_Torrents_Add_Lifetime.Designer.cs | 461 ++++++++++++++++++ .../20220206225658_Torrents_Add_Lifetime.cs | 26 + .../Migrations/DataContextModelSnapshot.cs | 3 + server/RdtClient.Data/Models/Data/Torrent.cs | 1 + .../Models/Internal/DbSettings.cs | 1 + .../RdtClient.Service/Services/QBittorrent.cs | 2 + .../Services/TorrentRunner.cs | 27 +- server/RdtClient.Service/Services/Torrents.cs | 1 + 19 files changed, 582 insertions(+), 7 deletions(-) create mode 100644 server/RdtClient.Data/Migrations/20220206225658_Torrents_Add_Lifetime.Designer.cs create mode 100644 server/RdtClient.Data/Migrations/20220206225658_Torrents_Add_Lifetime.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index bc85b6b..a48e106 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2.0.6] - 2022-02-06 ### Added - Added setting to automatically delete torrents in the state of error after a certain amount of time. +- Added lifetime setting to automatically expire torrents after a certain amount of time. ## [2.0.5] - 2022-01-11 ### Changed diff --git a/client/src/app/add-new-torrent/add-new-torrent.component.html b/client/src/app/add-new-torrent/add-new-torrent.component.html index a61dbab..92b975d 100644 --- a/client/src/app/add-new-torrent/add-new-torrent.component.html +++ b/client/src/app/add-new-torrent/add-new-torrent.component.html @@ -131,13 +131,23 @@
- +

When a download has been in error for this many minutes, delete it from the provider and the client. 0 to disable.

+
+ +
+ +
+

+ The maximum lifetime of a torrent in minutes. When this time has passed, mark the torrent as error. If the torrent + is completed and has downloads, the lifetime setting will not apply. 0 to disable. +

+
diff --git a/client/src/app/add-new-torrent/add-new-torrent.component.ts b/client/src/app/add-new-torrent/add-new-torrent.component.ts index ec3fda9..7050b12 100644 --- a/client/src/app/add-new-torrent/add-new-torrent.component.ts +++ b/client/src/app/add-new-torrent/add-new-torrent.component.ts @@ -27,6 +27,7 @@ export class AddNewTorrentComponent implements OnInit { public downloadRetryAttempts: number = 3; public torrentRetryAttempts: number = 1; public torrentDeleteOnError: number = 0; + public torrentLifetime: number = 0; public availableFiles: TorrentFileAvailability[]; public downloadFiles: { [key: string]: boolean } = {}; diff --git a/client/src/app/models/torrent.model.ts b/client/src/app/models/torrent.model.ts index 23f5996..1ce98b0 100644 --- a/client/src/app/models/torrent.model.ts +++ b/client/src/app/models/torrent.model.ts @@ -20,6 +20,7 @@ export class Torrent { public downloadRetryAttempts: number; public torrentRetryAttempts: number; public deleteOnError: number; + public lifetime: number; public priority: number; public error: string; diff --git a/client/src/app/settings/settings.component.html b/client/src/app/settings/settings.component.html index ea39b32..21f7eb0 100644 --- a/client/src/app/settings/settings.component.html +++ b/client/src/app/settings/settings.component.html @@ -291,12 +291,23 @@
- +

When a download has been in error for this many minutes, delete it from the provider and the client. 0 to disable.

+ +
+ +
+ +
+

+ The maximum lifetime of a torrent in minutes. When this time has passed, mark the torrent as error. If the torrent + is completed and has downloads, the lifetime setting will not apply. 0 to disable. +

+
diff --git a/client/src/app/settings/settings.component.ts b/client/src/app/settings/settings.component.ts index 1468ef9..4fc157f 100644 --- a/client/src/app/settings/settings.component.ts +++ b/client/src/app/settings/settings.component.ts @@ -46,6 +46,7 @@ export class SettingsComponent implements OnInit { public settingDownloadRetryAttempts: number; public settingTorrentRetryAttempts: number; public settingDeleteOnError: number; + public settingTorrentLifetime: number; constructor(private settingsService: SettingsService) {} @@ -80,6 +81,7 @@ export class SettingsComponent implements OnInit { this.settingDownloadRetryAttempts = parseInt(this.getSetting(results, 'DownloadRetryAttempts'), 10); this.settingTorrentRetryAttempts = parseInt(this.getSetting(results, 'TorrentRetryAttempts'), 10); this.settingDeleteOnError = parseInt(this.getSetting(results, 'DeleteOnError'), 10); + this.settingTorrentLifetime = parseInt(this.getSetting(results, 'TorrentLifetime'), 10); }, (err) => { this.error = err.error; @@ -176,6 +178,10 @@ export class SettingsComponent implements OnInit { settingId: 'DeleteOnError', value: (this.settingDeleteOnError ?? 0).toString(), }, + { + settingId: 'TorrentLifetime', + value: (this.settingTorrentLifetime ?? 0).toString(), + }, ]; this.settingsService.update(settings).subscribe( diff --git a/client/src/app/torrent/torrent.component.html b/client/src/app/torrent/torrent.component.html index 662c980..fb72c63 100644 --- a/client/src/app/torrent/torrent.component.html +++ b/client/src/app/torrent/torrent.component.html @@ -511,6 +511,23 @@ disable.

+
+ +
+ +
+

+ The maximum lifetime of a torrent in minutes. When this time has passed, mark the torrent as error. If the + torrent is completed and has downloads, the lifetime setting will not apply. 0 to disable. +

+