From 25f8c70b1796dac8368dd7e26e3c22a6fc06d7ea Mon Sep 17 00:00:00 2001 From: Roger Far Date: Sun, 6 Feb 2022 15:34:36 -0700 Subject: [PATCH] Added setting to automatically delete torrents in the state of error after a certain amount of time. --- CHANGELOG.md | 4 + .../add-new-torrent.component.html | 10 + .../add-new-torrent.component.ts | 12 +- client/src/app/models/torrent.model.ts | 1 + .../src/app/settings/settings.component.html | 26 +- client/src/app/settings/settings.component.ts | 34 +- client/src/app/torrent/torrent.component.html | 12 +- client/src/app/torrent/torrent.component.ts | 4 + server/RdtClient.Data/Data/DataContext.cs | 6 + server/RdtClient.Data/Data/SettingData.cs | 5 +- server/RdtClient.Data/Data/TorrentData.cs | 4 +- ...254_Torrents_Add_DeleteOnError.Designer.cs | 458 ++++++++++++++++++ ...220206223254_Torrents_Add_DeleteOnError.cs | 26 + .../Migrations/DataContextModelSnapshot.cs | 22 +- server/RdtClient.Data/Models/Data/Torrent.cs | 1 + .../Models/Internal/DbSettings.cs | 1 + .../RdtClient.Service/Services/QBittorrent.cs | 2 + .../Services/TorrentRunner.cs | 11 + server/RdtClient.Service/Services/Torrents.cs | 1 + 19 files changed, 605 insertions(+), 35 deletions(-) create mode 100644 server/RdtClient.Data/Migrations/20220206223254_Torrents_Add_DeleteOnError.Designer.cs create mode 100644 server/RdtClient.Data/Migrations/20220206223254_Torrents_Add_DeleteOnError.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index a951796..bc85b6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.0.6] - 2022-02-06 +### Added +- Added setting to automatically delete torrents in the state of error after a certain amount of time. + ## [2.0.5] - 2022-01-11 ### Changed - Updated AllDebrid provider to fix issue with ID's not being a number. 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 3aa11b2..a61dbab 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 @@ -128,6 +128,16 @@ error it will retry the full torrent this many times before marking it failed.

+
+ +
+ +
+

+ When a download has been in error for this many minutes, delete it from the provider and the client. 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 e9daf86..ec3fda9 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 @@ -26,6 +26,7 @@ export class AddNewTorrentComponent implements OnInit { public downloadRetryAttempts: number = 3; public torrentRetryAttempts: number = 1; + public torrentDeleteOnError: number = 0; public availableFiles: TorrentFileAvailability[]; public downloadFiles: { [key: string]: boolean } = {}; @@ -36,9 +37,13 @@ export class AddNewTorrentComponent implements OnInit { private selectedFile: File; - constructor(private router: Router, private torrentService: TorrentService, private settingsService: SettingsService) { - this.settingsService.get().subscribe(settings => { - this.provider = settings.firstOrDefault(m => m.settingId === 'Provider')?.value; + constructor( + private router: Router, + private torrentService: TorrentService, + private settingsService: SettingsService + ) { + this.settingsService.get().subscribe((settings) => { + this.provider = settings.firstOrDefault((m) => m.settingId === 'Provider')?.value; }); } @@ -110,6 +115,7 @@ export class AddNewTorrentComponent implements OnInit { torrent.priority = this.priority; torrent.torrentRetryAttempts = this.torrentRetryAttempts; torrent.downloadRetryAttempts = this.downloadRetryAttempts; + torrent.deleteOnError = this.torrentDeleteOnError; if (this.magnetLink) { this.torrentService.uploadMagnet(this.magnetLink, torrent).subscribe( diff --git a/client/src/app/models/torrent.model.ts b/client/src/app/models/torrent.model.ts index 09eb2fe..23f5996 100644 --- a/client/src/app/models/torrent.model.ts +++ b/client/src/app/models/torrent.model.ts @@ -19,6 +19,7 @@ export class Torrent { public retryCount: number; public downloadRetryAttempts: number; public torrentRetryAttempts: number; + public deleteOnError: 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 c5be409..ea39b32 100644 --- a/client/src/app/settings/settings.component.html +++ b/client/src/app/settings/settings.component.html @@ -122,6 +122,14 @@

Maximum amount of downloads that get unpacked on your host at the same time.

+ +
+ +
+ +
+

Maximum amount of downloads that get unpacked on your host at the same time.

+
@@ -189,7 +197,7 @@
- +

This is the URL to your Aria2c instance. It must end in /jsonrpc. A common URL is @@ -200,7 +208,7 @@

- +

The secret of your Aria2c instance. Optional.

@@ -264,7 +272,7 @@
- +

When a single download fails it will retry it this many times before marking it as failed.

@@ -272,13 +280,23 @@
- +

When a single download has failed multiple times (see setting above) or when the torrent itself received an error it will retry the full torrent this many times before marking it failed.

+ +
+ +
+ +
+

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

+
diff --git a/client/src/app/settings/settings.component.ts b/client/src/app/settings/settings.component.ts index 1c2c65c..1468ef9 100644 --- a/client/src/app/settings/settings.component.ts +++ b/client/src/app/settings/settings.component.ts @@ -41,12 +41,11 @@ export class SettingsComponent implements OnInit { public settingMinFileSize: number; public settingOnlyDownloadAvailableFiles: boolean; public settingProxyServer: string; - - public aria2cUrl: string; - public aria2cSecret: string; - - public downloadRetryAttempts: number; - public torrentRetryAttempts: number; + public settingAria2cUrl: string; + public settingAria2cSecret: string; + public settingDownloadRetryAttempts: number; + public settingTorrentRetryAttempts: number; + public settingDeleteOnError: number; constructor(private settingsService: SettingsService) {} @@ -76,10 +75,11 @@ export class SettingsComponent implements OnInit { this.settingMinFileSize = parseInt(this.getSetting(results, 'MinFileSize'), 10); this.settingOnlyDownloadAvailableFiles = this.getSetting(results, 'OnlyDownloadAvailableFiles') === '1'; this.settingProxyServer = this.getSetting(results, 'ProxyServer'); - this.aria2cUrl = this.getSetting(results, 'Aria2cUrl'); - this.aria2cSecret = this.getSetting(results, 'Aria2cSecret'); - this.downloadRetryAttempts = parseInt(this.getSetting(results, 'DownloadRetryAttempts'), 10); - this.torrentRetryAttempts = parseInt(this.getSetting(results, 'TorrentRetryAttempts'), 10); + this.settingAria2cUrl = this.getSetting(results, 'Aria2cUrl'); + this.settingAria2cSecret = this.getSetting(results, 'Aria2cSecret'); + this.settingDownloadRetryAttempts = parseInt(this.getSetting(results, 'DownloadRetryAttempts'), 10); + this.settingTorrentRetryAttempts = parseInt(this.getSetting(results, 'TorrentRetryAttempts'), 10); + this.settingDeleteOnError = parseInt(this.getSetting(results, 'DeleteOnError'), 10); }, (err) => { this.error = err.error; @@ -158,19 +158,23 @@ export class SettingsComponent implements OnInit { }, { settingId: 'Aria2cUrl', - value: this.aria2cUrl, + value: this.settingAria2cUrl, }, { settingId: 'Aria2cSecret', - value: this.aria2cSecret, + value: this.settingAria2cSecret, }, { settingId: 'DownloadRetryAttempts', - value: (this.downloadRetryAttempts ?? 0).toString(), + value: (this.settingDownloadRetryAttempts ?? 0).toString(), }, { settingId: 'TorrentRetryAttempts', - value: (this.torrentRetryAttempts ?? 0).toString(), + value: (this.settingTorrentRetryAttempts ?? 0).toString(), + }, + { + settingId: 'DeleteOnError', + value: (this.settingDeleteOnError ?? 0).toString(), }, ]; @@ -242,7 +246,7 @@ export class SettingsComponent implements OnInit { this.testAria2cConnectionError = null; this.testAria2cConnectionSuccess = null; - this.settingsService.testAria2cConnection(this.aria2cUrl, this.aria2cSecret).subscribe( + this.settingsService.testAria2cConnection(this.settingAria2cUrl, this.settingAria2cSecret).subscribe( (result) => { this.saving = false; this.testAria2cConnectionSuccess = result.version; diff --git a/client/src/app/torrent/torrent.component.html b/client/src/app/torrent/torrent.component.html index afc1c74..662c980 100644 --- a/client/src/app/torrent/torrent.component.html +++ b/client/src/app/torrent/torrent.component.html @@ -37,7 +37,7 @@
- {{ torrent.retryCount }} / {{ torrent.torrentRetryAttempts}} + {{ torrent.retryCount }} / {{ torrent.torrentRetryAttempts }}
@@ -501,6 +501,16 @@ error it will retry the full torrent this many times before marking it failed.

+
+ +
+ +
+

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

+