Fixed: Failed download handling should now only report a download wasn't grabbed by sonarr if the download actually failed.

This commit is contained in:
Taloth Saldono 2015-02-22 13:43:14 +01:00
parent 30849e6356
commit 6095855102
2 changed files with 39 additions and 11 deletions

View File

@ -68,6 +68,28 @@ namespace NzbDrone.Core.Test.Download
AssertDownloadNotFailed(); AssertDownloadNotFailed();
} }
[Test]
public void should_warn_if_matching_history_is_not_found()
{
_trackedDownload.DownloadItem.Status = DownloadItemStatus.Failed;
GivenNoGrabbedHistory();
Subject.Process(_trackedDownload);
_trackedDownload.StatusMessages.Should().NotBeEmpty();
}
[Test]
public void should_not_warn_if_matching_history_is_not_found_and_not_failed()
{
_trackedDownload.DownloadItem.Status = DownloadItemStatus.Failed;
GivenNoGrabbedHistory();
Subject.Process(_trackedDownload);
_trackedDownload.StatusMessages.Should().NotBeEmpty();
}
[Test] [Test]
public void should_mark_failed_if_encrypted() public void should_mark_failed_if_encrypted()
{ {

View File

@ -53,6 +53,19 @@ namespace NzbDrone.Core.Download
} }
public void Process(TrackedDownload trackedDownload) public void Process(TrackedDownload trackedDownload)
{
string failure = null;
if (trackedDownload.DownloadItem.IsEncrypted)
{
failure = "Encrypted download detected";
}
else if (trackedDownload.DownloadItem.Status == DownloadItemStatus.Failed)
{
failure = trackedDownload.DownloadItem.Message ?? "Failed download detected";
}
if (failure != null)
{ {
var grabbedItems = _historyService.Find(trackedDownload.DownloadItem.DownloadId, HistoryEventType.Grabbed) var grabbedItems = _historyService.Find(trackedDownload.DownloadItem.DownloadId, HistoryEventType.Grabbed)
.ToList(); .ToList();
@ -63,15 +76,8 @@ namespace NzbDrone.Core.Download
return; return;
} }
if (trackedDownload.DownloadItem.IsEncrypted)
{
trackedDownload.State = TrackedDownloadStage.DownloadFailed; trackedDownload.State = TrackedDownloadStage.DownloadFailed;
PublishDownloadFailedEvent(grabbedItems, "Encrypted download detected", trackedDownload); PublishDownloadFailedEvent(grabbedItems, failure, trackedDownload);
}
else if (trackedDownload.DownloadItem.Status == DownloadItemStatus.Failed)
{
trackedDownload.State = TrackedDownloadStage.DownloadFailed;
PublishDownloadFailedEvent(grabbedItems, trackedDownload.DownloadItem.Message, trackedDownload);
} }
} }