Fixed issue where a deleted torrent could be retried.
This commit is contained in:
parent
b3dd856410
commit
dd8102b0b6
3 changed files with 12 additions and 11 deletions
|
|
@ -177,7 +177,7 @@ namespace RdtClient.Data.Data
|
||||||
await VoidCache();
|
await VoidCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateComplete(Guid torrentId, String error, DateTimeOffset? datetime)
|
public async Task UpdateComplete(Guid torrentId, String error, DateTimeOffset? datetime, Boolean retry)
|
||||||
{
|
{
|
||||||
var dbTorrent = await _dataContext.Torrents.FirstOrDefaultAsync(m => m.TorrentId == torrentId);
|
var dbTorrent = await _dataContext.Torrents.FirstOrDefaultAsync(m => m.TorrentId == torrentId);
|
||||||
|
|
||||||
|
|
@ -191,13 +191,13 @@ namespace RdtClient.Data.Data
|
||||||
var downloads = await _dataContext.Downloads.AsNoTracking().Where(m => m.TorrentId == torrentId).ToListAsync();
|
var downloads = await _dataContext.Downloads.AsNoTracking().Where(m => m.TorrentId == torrentId).ToListAsync();
|
||||||
var downloadWithErrors = downloads.Where(m => !String.IsNullOrWhiteSpace(m.Error)).ToList();
|
var downloadWithErrors = downloads.Where(m => !String.IsNullOrWhiteSpace(m.Error)).ToList();
|
||||||
|
|
||||||
if (downloads.Any())
|
if (downloadWithErrors.Any())
|
||||||
{
|
{
|
||||||
error = $"{downloadWithErrors.Count}/{downloads.Count} downloads failed with errors";
|
error = $"{downloadWithErrors.Count}/{downloads.Count} downloads failed with errors";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!String.IsNullOrWhiteSpace(error))
|
if (!String.IsNullOrWhiteSpace(error) && retry)
|
||||||
{
|
{
|
||||||
if (dbTorrent.RetryCount < dbTorrent.TorrentRetryAttempts)
|
if (dbTorrent.RetryCount < dbTorrent.TorrentRetryAttempts)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -480,7 +480,7 @@ namespace RdtClient.Service.Services
|
||||||
|
|
||||||
Log($"Received RealDebrid error: {torrent.RdStatusRaw}, not processing further", torrent);
|
Log($"Received RealDebrid error: {torrent.RdStatusRaw}, not processing further", torrent);
|
||||||
|
|
||||||
await _torrents.UpdateComplete(torrent.TorrentId, $"Received RealDebrid error: {torrent.RdStatusRaw}.", DateTimeOffset.UtcNow);
|
await _torrents.UpdateComplete(torrent.TorrentId, $"Received RealDebrid error: {torrent.RdStatusRaw}.", DateTimeOffset.UtcNow, true);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -567,7 +567,7 @@ namespace RdtClient.Service.Services
|
||||||
{
|
{
|
||||||
Log($"All downloads complete, marking torrent as complete", torrent);
|
Log($"All downloads complete, marking torrent as complete", torrent);
|
||||||
|
|
||||||
await _torrents.UpdateComplete(torrent.TorrentId, null, DateTimeOffset.UtcNow);
|
await _torrents.UpdateComplete(torrent.TorrentId, null, DateTimeOffset.UtcNow, true);
|
||||||
|
|
||||||
switch (torrent.FinishedAction)
|
switch (torrent.FinishedAction)
|
||||||
{
|
{
|
||||||
|
|
@ -600,7 +600,7 @@ namespace RdtClient.Service.Services
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex.Message, $"Torrent processing result in an unexpected exception: {ex.Message}");
|
_logger.LogError(ex.Message, $"Torrent processing result in an unexpected exception: {ex.Message}");
|
||||||
await _torrents.UpdateComplete(torrent.TorrentId, ex.Message, DateTimeOffset.UtcNow);
|
await _torrents.UpdateComplete(torrent.TorrentId, ex.Message, DateTimeOffset.UtcNow, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ namespace RdtClient.Service.Services
|
||||||
|
|
||||||
Log($"Deleting", torrent);
|
Log($"Deleting", torrent);
|
||||||
|
|
||||||
await UpdateComplete(torrentId, "Torrent deleted", DateTimeOffset.UtcNow);
|
await UpdateComplete(torrentId, "Torrent deleted", DateTimeOffset.UtcNow, false);
|
||||||
|
|
||||||
foreach (var download in torrent.Downloads)
|
foreach (var download in torrent.Downloads)
|
||||||
{
|
{
|
||||||
|
|
@ -374,7 +374,8 @@ namespace RdtClient.Service.Services
|
||||||
|
|
||||||
Log($"Retrying Torrent", torrent);
|
Log($"Retrying Torrent", torrent);
|
||||||
|
|
||||||
await UpdateComplete(torrent.TorrentId, "Retrying Torrent", DateTimeOffset.UtcNow);
|
await UpdateComplete(torrent.TorrentId, "Retrying Torrent", DateTimeOffset.UtcNow, false);
|
||||||
|
await UpdateRetry(torrent.TorrentId, null, 0);
|
||||||
|
|
||||||
foreach (var download in torrent.Downloads)
|
foreach (var download in torrent.Downloads)
|
||||||
{
|
{
|
||||||
|
|
@ -464,12 +465,12 @@ namespace RdtClient.Service.Services
|
||||||
|
|
||||||
await _downloads.Reset(downloadId);
|
await _downloads.Reset(downloadId);
|
||||||
|
|
||||||
await _torrentData.UpdateComplete(download.TorrentId, null, null);
|
await _torrentData.UpdateComplete(download.TorrentId, null, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateComplete(Guid torrentId, String error, DateTimeOffset datetime)
|
public async Task UpdateComplete(Guid torrentId, String error, DateTimeOffset datetime, Boolean retry)
|
||||||
{
|
{
|
||||||
await _torrentData.UpdateComplete(torrentId, error, datetime);
|
await _torrentData.UpdateComplete(torrentId, error, datetime, retry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateFilesSelected(Guid torrentId, DateTimeOffset datetime)
|
public async Task UpdateFilesSelected(Guid torrentId, DateTimeOffset datetime)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue