Add proper retry mechanism for Aria2.
This commit is contained in:
parent
11c65d0017
commit
0f4d896e53
4 changed files with 47 additions and 18 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
<a class="navbar-item"> Profile </a>
|
||||
<a class="navbar-item" (click)="logout()"> Logout </a>
|
||||
<hr class="navbar-divider" />
|
||||
<div class="navbar-item">Version 1.8.8</div>
|
||||
<div class="navbar-item">Version 1.8.9</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ namespace RdtClient.Service.Services.Downloaders
|
|||
public event EventHandler<DownloadCompleteEventArgs> DownloadComplete;
|
||||
public event EventHandler<DownloadProgressEventArgs> 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<String>
|
||||
{
|
||||
_uri
|
||||
},
|
||||
new Dictionary<String, Object>
|
||||
{
|
||||
{
|
||||
"dir", path
|
||||
},
|
||||
{
|
||||
"out", fileName
|
||||
}
|
||||
});
|
||||
|
||||
var retryCount = 0;
|
||||
while(true)
|
||||
{
|
||||
try
|
||||
{
|
||||
_gid ??= await _aria2NetClient.AddUri(new List<String>
|
||||
{
|
||||
_uri
|
||||
},
|
||||
new Dictionary<String, Object>
|
||||
{
|
||||
{
|
||||
"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();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue