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 @@ namespace NzbDrone.Core.Download
{ {
trackedDownload.State = TrackedDownloadState.Imported; 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 else
{ {
@ -137,13 +137,13 @@ namespace NzbDrone.Core.Download
importedItems.First().Data[DownloadTrackingService.DOWNLOAD_CLIENT_ID] = grabbedItems.First().Data[DownloadTrackingService.DOWNLOAD_CLIENT_ID]; importedItems.First().Data[DownloadTrackingService.DOWNLOAD_CLIENT_ID] = grabbedItems.First().Data[DownloadTrackingService.DOWNLOAD_CLIENT_ID];
_historyService.UpdateHistoryData(importedItems.First().Id, importedItems.First().Data); _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; return;
} }
} }
} }
_logger.Debug("Storage path does not exist: " + trackedDownload.DownloadItem.Title); _logger.Trace("Storage path does not exist: " + trackedDownload.DownloadItem.Title);
return; return;
} }
} }

View File

@ -54,7 +54,7 @@ namespace NzbDrone.Core.Download
if (!grabbedItems.Any()) 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; return;
} }
@ -64,7 +64,7 @@ namespace NzbDrone.Core.Download
if (failedItems.Any()) if (failedItems.Any())
{ {
_logger.Debug("Already added to history as failed"); _logger.Trace("Already added to history as failed: " + trackedDownload.DownloadItem.Title);
} }
else else
{ {
@ -78,7 +78,7 @@ namespace NzbDrone.Core.Download
if (!grabbedItems.Any()) 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; return;
} }
@ -86,13 +86,13 @@ namespace NzbDrone.Core.Download
if (trackedDownload.DownloadItem.Message.Equals("Unpacking failed, write error or disk is full?", if (trackedDownload.DownloadItem.Message.Equals("Unpacking failed, write error or disk is full?",
StringComparison.InvariantCultureIgnoreCase)) 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; return;
} }
if (FailedDownloadForRecentRelease(downloadClient, trackedDownload, grabbedItems)) 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; return;
} }
@ -102,7 +102,7 @@ namespace NzbDrone.Core.Download
if (failedItems.Any()) if (failedItems.Any())
{ {
_logger.Debug("Already added to history as failed"); _logger.Trace("Already added to history as failed: " + trackedDownload.DownloadItem.Title);
} }
else else
{ {
@ -110,6 +110,18 @@ namespace NzbDrone.Core.Download
} }
} }
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) if (_configService.RemoveFailedDownloads && trackedDownload.State == TrackedDownloadState.DownloadFailed)
{ {
try try
@ -121,7 +133,7 @@ namespace NzbDrone.Core.Download
} }
catch (NotSupportedException) 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 @@ namespace NzbDrone.Core.Download
if (!Double.TryParse(matchingHistoryItems.First().Data.GetValueOrDefault("ageHours"), out ageHours)) 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; return false;
} }
if (ageHours > _configService.BlacklistGracePeriod) 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; return false;
} }
if (trackedDownload.RetryCount >= _configService.BlacklistRetryLimit) if (trackedDownload.RetryCount >= _configService.BlacklistRetryLimit)
{ {
_logger.Debug("Retry limit reached"); _logger.Debug("Retry limit reached: " + trackedDownload.DownloadItem.Title);
return false; return false;
} }
if (trackedDownload.RetryCount == 0 || trackedDownload.LastRetry.AddMinutes(_configService.BlacklistRetryInterval) < DateTime.UtcNow) 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.LastRetry = DateTime.UtcNow;
trackedDownload.RetryCount++; trackedDownload.RetryCount++;