Fixed simple downloader retrying.
This commit is contained in:
parent
0d5d28483b
commit
075f494ec6
3 changed files with 15 additions and 5 deletions
|
|
@ -63,7 +63,7 @@ namespace RdtClient.Service.Services
|
|||
Downloader.DownloadComplete += (_, args) =>
|
||||
{
|
||||
Finished = true;
|
||||
Error = args.Error;
|
||||
Error ??= args.Error;
|
||||
};
|
||||
|
||||
Downloader.DownloadProgress += (_, args) =>
|
||||
|
|
@ -74,13 +74,18 @@ namespace RdtClient.Service.Services
|
|||
};
|
||||
|
||||
var result = await Downloader.Download();
|
||||
|
||||
|
||||
await Task.Delay(1000);
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (Downloader != null)
|
||||
{
|
||||
await Downloader.Cancel();
|
||||
}
|
||||
|
||||
Error = $"An unexpected error occurred preparing download {_download.Link} for torrent {_torrent.RdName}: {ex.Message}";
|
||||
Finished = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ namespace RdtClient.Service.Services.Downloaders
|
|||
{
|
||||
await StartDownloadTask();
|
||||
});
|
||||
|
||||
return null;
|
||||
|
||||
return Task.FromResult<String>(null);
|
||||
}
|
||||
|
||||
public Task Cancel()
|
||||
|
|
@ -137,6 +137,11 @@ namespace RdtClient.Service.Services.Downloaders
|
|||
}
|
||||
}
|
||||
|
||||
if (_cancelled)
|
||||
{
|
||||
throw new Exception("Download cancelled");
|
||||
}
|
||||
|
||||
if (timeout <= DateTimeOffset.UtcNow)
|
||||
{
|
||||
throw new Exception($"Download timed out");
|
||||
|
|
|
|||
|
|
@ -184,8 +184,8 @@ namespace RdtClient.Service.Services
|
|||
{
|
||||
Log($"Retrying download", download, download.Torrent);
|
||||
|
||||
await _downloads.UpdateRetryCount(downloadId, download.RetryCount + 1);
|
||||
await _downloads.Reset(downloadId);
|
||||
await _downloads.UpdateRetryCount(downloadId, download.RetryCount + 1);
|
||||
}
|
||||
else if (download.Torrent.RetryCount < TorrentRetryCount)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue