From 399456c815a53f7899647c7e56eefc7b75c4e99a Mon Sep 17 00:00:00 2001 From: Roger Far Date: Mon, 11 Oct 2021 13:53:05 -0600 Subject: [PATCH] Fixed retrying of torrents. --- server/RdtClient.Service/Services/TorrentRunner.cs | 1 - server/RdtClient.Service/Services/Torrents.cs | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/server/RdtClient.Service/Services/TorrentRunner.cs b/server/RdtClient.Service/Services/TorrentRunner.cs index 2765d8a..b9b5f75 100644 --- a/server/RdtClient.Service/Services/TorrentRunner.cs +++ b/server/RdtClient.Service/Services/TorrentRunner.cs @@ -115,7 +115,6 @@ namespace RdtClient.Service.Services { Log.Debug($"Processing active download {downloadId}: error {downloadClient.Error}, download retry count {download.RetryCount}/{DownloadRetryCount}, torrent retry count {download.Torrent.RetryCount}/{TorrentRetryCount}, retrying torrent"); - await _torrents.UpdateRetryCount(download.TorrentId, download.Torrent.RetryCount + 1); await _torrents.RetryTorrent(download.TorrentId); } else diff --git a/server/RdtClient.Service/Services/Torrents.cs b/server/RdtClient.Service/Services/Torrents.cs index 3bd457b..c470f98 100644 --- a/server/RdtClient.Service/Services/Torrents.cs +++ b/server/RdtClient.Service/Services/Torrents.cs @@ -386,6 +386,8 @@ namespace RdtClient.Service.Services { var torrent = await _torrentData.GetById(torrentId); + var newRetryCount = torrent.RetryCount + 1; + foreach (var download in torrent.Downloads) { while (TorrentRunner.ActiveDownloadClients.TryGetValue(download.DownloadId, out var downloadClient)) @@ -429,6 +431,8 @@ namespace RdtClient.Service.Services torrent.DownloadMinSize, torrent.DownloadManualFiles); } + + await _torrentData.UpdateRetryCount(torrent.TorrentId, newRetryCount); } finally { @@ -635,10 +639,5 @@ namespace RdtClient.Service.Services await _torrentData.UpdateRdData(torrent); } } - - public async Task UpdateRetryCount(Guid torrentId, Int32 retryCount) - { - await _torrentData.UpdateRetryCount(torrentId, retryCount); - } } }