1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 10:32:35 +01:00

Fixed: Manually marking a release as failed will now also remove it from the queue in drone and, if enabled, remove it from the download client.

This commit is contained in:
Taloth Saldono 2014-06-25 00:50:30 +02:00
parent 839a2ac742
commit 1a6abfe635
2 changed files with 26 additions and 14 deletions

View File

@ -77,7 +77,7 @@ public void CheckForCompletedItem(IDownloadClient downloadClient, TrackedDownloa
{
trackedDownload.State = TrackedDownloadState.Imported;
_logger.Debug("Already added to history as imported: " + trackedDownload.DownloadItem.Title);
_logger.Trace("Already added to history as imported: " + trackedDownload.DownloadItem.Title);
}
else
{
@ -137,13 +137,13 @@ public void CheckForCompletedItem(IDownloadClient downloadClient, TrackedDownloa
importedItems.First().Data[DownloadTrackingService.DOWNLOAD_CLIENT_ID] = grabbedItems.First().Data[DownloadTrackingService.DOWNLOAD_CLIENT_ID];
_historyService.UpdateHistoryData(importedItems.First().Id, importedItems.First().Data);
_logger.Debug("Storage path does not exist, but found probable drone factory ImportEvent: " + trackedDownload.DownloadItem.Title);
_logger.Trace("Storage path does not exist, but found probable drone factory ImportEvent: " + trackedDownload.DownloadItem.Title);
return;
}
}
}
_logger.Debug("Storage path does not exist: " + trackedDownload.DownloadItem.Title);
_logger.Trace("Storage path does not exist: " + trackedDownload.DownloadItem.Title);
return;
}
}

View File

@ -54,7 +54,7 @@ public void CheckForFailedItem(IDownloadClient downloadClient, TrackedDownload t
if (!grabbedItems.Any())
{
_logger.Debug("Download was not grabbed by drone, ignoring.");
_logger.Trace("Download was not grabbed by drone, ignoring download: " + trackedDownload.DownloadItem.Title);
return;
}
@ -64,7 +64,7 @@ public void CheckForFailedItem(IDownloadClient downloadClient, TrackedDownload t
if (failedItems.Any())
{
_logger.Debug("Already added to history as failed");
_logger.Trace("Already added to history as failed: " + trackedDownload.DownloadItem.Title);
}
else
{
@ -78,7 +78,7 @@ public void CheckForFailedItem(IDownloadClient downloadClient, TrackedDownload t
if (!grabbedItems.Any())
{
_logger.Debug("Download was not grabbed by drone, ignoring.");
_logger.Trace("Download was not grabbed by drone, ignoring download: " + trackedDownload.DownloadItem.Title);
return;
}
@ -86,13 +86,13 @@ public void CheckForFailedItem(IDownloadClient downloadClient, TrackedDownload t
if (trackedDownload.DownloadItem.Message.Equals("Unpacking failed, write error or disk is full?",
StringComparison.InvariantCultureIgnoreCase))
{
_logger.Debug("Failed due to lack of disk space, do not blacklist");
_logger.Trace("Failed due to lack of disk space, do not blacklist: " + trackedDownload.DownloadItem.Title);
return;
}
if (FailedDownloadForRecentRelease(downloadClient, trackedDownload, grabbedItems))
{
_logger.Debug("Recent release Failed, do not blacklist");
_logger.Trace("Recent release Failed, do not blacklist: " + trackedDownload.DownloadItem.Title);
return;
}
@ -102,7 +102,7 @@ public void CheckForFailedItem(IDownloadClient downloadClient, TrackedDownload t
if (failedItems.Any())
{
_logger.Debug("Already added to history as failed");
_logger.Trace("Already added to history as failed: " + trackedDownload.DownloadItem.Title);
}
else
{
@ -110,6 +110,18 @@ public void CheckForFailedItem(IDownloadClient downloadClient, TrackedDownload t
}
}
if (trackedDownload.DownloadItem.Status != DownloadItemStatus.Failed && trackedDownload.State == TrackedDownloadState.Downloading)
{
var grabbedItems = GetHistoryItems(grabbedHistory, trackedDownload.DownloadItem.DownloadClientId);
var failedItems = GetHistoryItems(failedHistory, trackedDownload.DownloadItem.DownloadClientId);
if (grabbedItems.Any() && failedItems.Any())
{
_logger.Trace("Already added to history as failed, updating tracked state: " + trackedDownload.DownloadItem.Title);
trackedDownload.State = TrackedDownloadState.DownloadFailed;
}
}
if (_configService.RemoveFailedDownloads && trackedDownload.State == TrackedDownloadState.DownloadFailed)
{
try
@ -121,7 +133,7 @@ public void CheckForFailedItem(IDownloadClient downloadClient, TrackedDownload t
}
catch (NotSupportedException)
{
_logger.Debug("Removing item not supported by your download client");
_logger.Trace("Removing item not supported by your download client");
}
}
}
@ -132,25 +144,25 @@ private bool FailedDownloadForRecentRelease(IDownloadClient downloadClient, Trac
if (!Double.TryParse(matchingHistoryItems.First().Data.GetValueOrDefault("ageHours"), out ageHours))
{
_logger.Debug("Unable to determine age of failed download");
_logger.Debug("Unable to determine age of failed download: " + trackedDownload.DownloadItem.Title);
return false;
}
if (ageHours > _configService.BlacklistGracePeriod)
{
_logger.Debug("Failed download is older than the grace period");
_logger.Debug("Failed download is older than the grace period: " + trackedDownload.DownloadItem.Title);
return false;
}
if (trackedDownload.RetryCount >= _configService.BlacklistRetryLimit)
{
_logger.Debug("Retry limit reached");
_logger.Debug("Retry limit reached: " + trackedDownload.DownloadItem.Title);
return false;
}
if (trackedDownload.RetryCount == 0 || trackedDownload.LastRetry.AddMinutes(_configService.BlacklistRetryInterval) < DateTime.UtcNow)
{
_logger.Debug("Retrying failed release");
_logger.Debug("Retrying failed release: " + trackedDownload.DownloadItem.Title);
trackedDownload.LastRetry = DateTime.UtcNow;
trackedDownload.RetryCount++;