diff --git a/CHANGELOG.md b/CHANGELOG.md index 964d9a9..6a91aed 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). +## [1.8.9] - 2021-10-23 +### Changed +- Add delays between adding downloads to Aria2 to avoid Aria2 going down when adding a large amount of downloads. + ## [1.8.8] - 2021-10-21 ### Changed - Fixed starting downloads when RealDebrid reports ghost links in torrents. diff --git a/client/src/app/navbar/navbar.component.html b/client/src/app/navbar/navbar.component.html index a69d5b3..0caf767 100644 --- a/client/src/app/navbar/navbar.component.html +++ b/client/src/app/navbar/navbar.component.html @@ -55,7 +55,7 @@ Profile Logout - + diff --git a/package.json b/package.json index 0ad343c..2c74f2d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rdt-client", - "version": "1.8.8", + "version": "1.8.9", "description": "This is a web interface to manage your torrents on Real-Debrid.", "main": "index.js", "dependencies": { diff --git a/server/RdtClient.Service/Services/Downloaders/Aria2cDownloader.cs b/server/RdtClient.Service/Services/Downloaders/Aria2cDownloader.cs index ee8e51a..b87b945 100644 --- a/server/RdtClient.Service/Services/Downloaders/Aria2cDownloader.cs +++ b/server/RdtClient.Service/Services/Downloaders/Aria2cDownloader.cs @@ -13,6 +13,8 @@ namespace RdtClient.Service.Services.Downloaders public event EventHandler DownloadComplete; public event EventHandler DownloadProgress; + private const Int32 RetryCount = 5; + private readonly String _uri; private readonly String _filePath; @@ -32,8 +34,8 @@ namespace RdtClient.Service.Services.Downloaders _timer = new Timer(); _timer.Elapsed += OnTimedEvent; - - _timer.Interval = 100; + + _timer.Interval = 1000; _timer.Enabled = false; } @@ -53,20 +55,43 @@ namespace RdtClient.Service.Services.Downloaders _gid = null; } } - - _gid ??= await _aria2NetClient.AddUri(new List - { - _uri - }, - new Dictionary - { - { - "dir", path - }, - { - "out", fileName - } - }); + + var retryCount = 0; + while(true) + { + try + { + _gid ??= await _aria2NetClient.AddUri(new List + { + _uri + }, + new Dictionary + { + { + "dir", path + }, + { + "out", fileName + } + }); + + break; + } + catch + { + if (retryCount >= RetryCount) + { + throw; + } + + await Task.Delay(retryCount * 1000); + + retryCount++; + } + } + + // Add a delay to prevent sending too many Add requests to Aria2 at the same time. + await Task.Delay(1000); _timer.Start();