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 8fa2e4d..83fc19c 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 @@ -84,12 +84,43 @@
- +

Set the priority for this torrent where 1 is the highest. When empty it will be assigned the lowest priority.

+
+ +
+ +
+

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

+
+
+ +
+ +
+

+ 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. +

+
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 0353c96..d3b9681 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 @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { TorrentService } from 'src/app/torrent.service'; -import { TorrentFileAvailability } from '../models/torrent.model'; +import { Torrent, TorrentFileAvailability } from '../models/torrent.model'; @Component({ selector: 'app-add-new-torrent', @@ -21,6 +21,9 @@ export class AddNewTorrentComponent implements OnInit { public downloadMinSize: number = 0; + public downloadRetryAttempts: number = 3; + public torrentRetryAttempts: number = 1; + public availableFiles: TorrentFileAvailability[] = []; public downloadFiles: { [key: string]: boolean } = {}; public allSelected: boolean; @@ -91,46 +94,36 @@ export class AddNewTorrentComponent implements OnInit { downloadManualFiles = selectedFiles.join(','); } + const torrent = new Torrent(); + torrent.category = this.category; + torrent.downloadAction = this.downloadAction; + torrent.finishedAction = this.finishedAction; + torrent.downloadMinSize = this.downloadMinSize; + torrent.downloadManualFiles = downloadManualFiles; + torrent.priority = this.priority; + torrent.torrentRetryAttempts = this.torrentRetryAttempts; + torrent.downloadRetryAttempts = this.downloadRetryAttempts; + if (this.magnetLink) { - this.torrentService - .uploadMagnet( - this.magnetLink, - this.category, - this.downloadAction, - this.finishedAction, - this.downloadMinSize, - downloadManualFiles, - this.priority - ) - .subscribe( - () => { - this.router.navigate(['/']); - }, - (err) => { - this.error = err.error; - this.saving = false; - } - ); + this.torrentService.uploadMagnet(this.magnetLink, torrent).subscribe( + () => { + this.router.navigate(['/']); + }, + (err) => { + this.error = err.error; + this.saving = false; + } + ); } else if (this.selectedFile) { - this.torrentService - .uploadFile( - this.selectedFile, - this.category, - this.downloadAction, - this.finishedAction, - this.downloadMinSize, - downloadManualFiles, - this.priority - ) - .subscribe( - () => { - this.router.navigate(['/']); - }, - (err) => { - this.error = err.error; - this.saving = false; - } - ); + this.torrentService.uploadFile(this.selectedFile, torrent).subscribe( + () => { + this.router.navigate(['/']); + }, + (err) => { + this.error = err.error; + this.saving = false; + } + ); } else { this.error = 'No magnet or file uploaded'; this.saving = false; diff --git a/client/src/app/models/torrent.model.ts b/client/src/app/models/torrent.model.ts index 52e871b..09eb2fe 100644 --- a/client/src/app/models/torrent.model.ts +++ b/client/src/app/models/torrent.model.ts @@ -17,7 +17,11 @@ export class Torrent { public isFile: boolean; public retryCount: number; + public downloadRetryAttempts: number; + public torrentRetryAttempts: number; + public priority: number; + public error: string; public rdId: string; public rdName: string; diff --git a/client/src/app/settings/settings.component.html b/client/src/app/settings/settings.component.html index 2d39bb9..00f612e 100644 --- a/client/src/app/settings/settings.component.html +++ b/client/src/app/settings/settings.component.html @@ -204,6 +204,25 @@
+ +
+ +
+ +
+

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

+
+ +
+ +
+ +
+

+ 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. +

+
diff --git a/client/src/app/settings/settings.component.ts b/client/src/app/settings/settings.component.ts index 921098b..f01851a 100644 --- a/client/src/app/settings/settings.component.ts +++ b/client/src/app/settings/settings.component.ts @@ -42,6 +42,9 @@ export class SettingsComponent implements OnInit { public aria2cUrl: string; public aria2cSecret: string; + public downloadRetryAttempts: number; + public torrentRetryAttempts: number; + constructor(private settingsService: SettingsService) {} ngOnInit(): void { @@ -69,6 +72,8 @@ export class SettingsComponent implements OnInit { 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); }, (err) => { this.error = err.error; @@ -141,6 +146,14 @@ export class SettingsComponent implements OnInit { settingId: 'Aria2cSecret', value: this.aria2cSecret, }, + { + settingId: 'DownloadRetryAttempts', + value: (this.downloadRetryAttempts ?? 0).toString(), + }, + { + settingId: 'TorrentRetryAttempts', + value: (this.torrentRetryAttempts ?? 0).toString(), + }, ]; this.settingsService.update(settings).subscribe( diff --git a/client/src/app/torrent-status.pipe.ts b/client/src/app/torrent-status.pipe.ts index 3a70a9d..a0b33d5 100644 --- a/client/src/app/torrent-status.pipe.ts +++ b/client/src/app/torrent-status.pipe.ts @@ -9,6 +9,11 @@ export class TorrentStatusPipe implements PipeTransform { constructor(private pipe: FileSizePipe) {} transform(torrent: Torrent): string { + + if (torrent.error) { + return torrent.error; + } + if (torrent.downloads.length > 0) { const errors = torrent.downloads.where((m) => m.error != null); diff --git a/client/src/app/torrent.service.ts b/client/src/app/torrent.service.ts index d342d72..830f6ed 100644 --- a/client/src/app/torrent.service.ts +++ b/client/src/app/torrent.service.ts @@ -37,41 +37,17 @@ export class TorrentService { return this.http.get(`/Api/Torrents/Get/${torrentId}`); } - public uploadMagnet( - magnetLink: string, - category: string, - downloadAction: number, - finishedAction: number, - downloadMinSize: number, - downloadManualFiles: string, - priority: number - ): Observable { + public uploadMagnet(magnetLink: string, torrent: Torrent): Observable { return this.http.post(`/Api/Torrents/UploadMagnet`, { magnetLink, - category, - downloadAction, - finishedAction, - downloadMinSize, - downloadManualFiles, - priority, + torrent, }); } - public uploadFile( - file: File, - category: string, - downloadAction: number, - finishedAction: number, - downloadMinSize: number, - downloadManualFiles: string, - priority: number - ): Observable { + public uploadFile(file: File, torrent: Torrent): Observable { const formData: FormData = new FormData(); formData.append('file', file); - formData.append( - 'formData', - JSON.stringify({ category, downloadAction, finishedAction, downloadMinSize, downloadManualFiles, priority }) - ); + formData.append('formData', JSON.stringify(torrent)); return this.http.post(`/Api/Torrents/UploadFile`, formData); } diff --git a/client/src/app/torrent/torrent.component.html b/client/src/app/torrent/torrent.component.html index ad54a2c..8a08998 100644 --- a/client/src/app/torrent/torrent.component.html +++ b/client/src/app/torrent/torrent.component.html @@ -28,7 +28,7 @@
- +
@@ -37,7 +37,7 @@
- {{ torrent.retryCount }} / 2 + {{ torrent.retryCount }} / {{ torrent.torrentRetryAttempts}}
@@ -256,7 +256,7 @@
- {{ download.retryCount }} / 3 + {{ download.retryCount }} / {{ torrent.downloadRetryAttempts }}
@@ -470,6 +470,37 @@ Set the priority for this torrent where 1 is the highest. When empty it will be assigned the lowest priority.

+
+ +
+ +
+

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

+
+
+ +
+ +
+

+ 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. +

+