Fixed: Failed downloads not removed from history will no longer be erroneously retried after restarting drone.
This commit is contained in:
parent
9e02a05733
commit
1bca66a0c2
|
@ -110,6 +110,18 @@ namespace NzbDrone.Core.Test.Download
|
||||||
.Verify(v => v.PublishEvent(It.Is<DownloadFailedEvent>(d => d.EpisodeIds.Count == count)), Times.Once());
|
.Verify(v => v.PublishEvent(It.Is<DownloadFailedEvent>(d => d.EpisodeIds.Count == count)), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void VerifyRetryDownload()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<IDownloadClient>()
|
||||||
|
.Verify(v => v.RetryDownload(It.IsAny<String>()), Times.Once());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void VerifyNoRetryDownload()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<IDownloadClient>()
|
||||||
|
.Verify(v => v.RetryDownload(It.IsAny<String>()), Times.Never());
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_process_if_no_download_client_history()
|
public void should_not_process_if_no_download_client_history()
|
||||||
{
|
{
|
||||||
|
@ -314,6 +326,7 @@ namespace NzbDrone.Core.Test.Download
|
||||||
Subject.Execute(new CheckForFinishedDownloadCommand());
|
Subject.Execute(new CheckForFinishedDownloadCommand());
|
||||||
|
|
||||||
VerifyFailedDownloads();
|
VerifyFailedDownloads();
|
||||||
|
VerifyNoRetryDownload();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -335,6 +348,31 @@ namespace NzbDrone.Core.Test.Download
|
||||||
Subject.Execute(new CheckForFinishedDownloadCommand());
|
Subject.Execute(new CheckForFinishedDownloadCommand());
|
||||||
|
|
||||||
VerifyFailedDownloads();
|
VerifyFailedDownloads();
|
||||||
|
VerifyNoRetryDownload();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_not_retry_if_already_failed()
|
||||||
|
{
|
||||||
|
GivenFailedDownloadClientHistory();
|
||||||
|
|
||||||
|
var historyGrabbed = Builder<History.History>.CreateListOfSize(1)
|
||||||
|
.Build()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
historyGrabbed.First().Data.Add("downloadClient", "SabnzbdClient");
|
||||||
|
historyGrabbed.First().Data.Add("downloadClientId", _failed.First().DownloadClientId);
|
||||||
|
historyGrabbed.First().Data.Add("ageHours", "1");
|
||||||
|
|
||||||
|
GivenGrabbedHistory(historyGrabbed);
|
||||||
|
GivenFailedHistory(historyGrabbed);
|
||||||
|
GivenGracePeriod(6);
|
||||||
|
GivenRetryLimit(1);
|
||||||
|
|
||||||
|
Subject.Execute(new CheckForFinishedDownloadCommand());
|
||||||
|
|
||||||
|
VerifyNoFailedDownloads();
|
||||||
|
VerifyNoRetryDownload();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -357,6 +395,7 @@ namespace NzbDrone.Core.Test.Download
|
||||||
Subject.Execute(new CheckForFinishedDownloadCommand());
|
Subject.Execute(new CheckForFinishedDownloadCommand());
|
||||||
|
|
||||||
VerifyFailedDownloads();
|
VerifyFailedDownloads();
|
||||||
|
VerifyNoRetryDownload();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -380,6 +419,7 @@ namespace NzbDrone.Core.Test.Download
|
||||||
Subject.Execute(new CheckForFinishedDownloadCommand());
|
Subject.Execute(new CheckForFinishedDownloadCommand());
|
||||||
|
|
||||||
VerifyNoFailedDownloads();
|
VerifyNoFailedDownloads();
|
||||||
|
VerifyRetryDownload();
|
||||||
|
|
||||||
ExceptionVerification.IgnoreWarns();
|
ExceptionVerification.IgnoreWarns();
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,15 @@ namespace NzbDrone.Core.Download
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var failedItems = GetHistoryItems(failedHistory, trackedDownload.DownloadItem.DownloadClientId);
|
||||||
|
|
||||||
|
if (failedItems.Any())
|
||||||
|
{
|
||||||
|
trackedDownload.State = TrackedDownloadState.DownloadFailed;
|
||||||
|
UpdateStatusMessage(trackedDownload, LogLevel.Debug, "Already added to history as failed.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//TODO: Make this more configurable (ignore failure reasons) to support changes and other failures that should be ignored
|
//TODO: Make this more configurable (ignore failure reasons) to support changes and other failures that should be ignored
|
||||||
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))
|
||||||
|
@ -112,14 +121,6 @@ namespace NzbDrone.Core.Download
|
||||||
|
|
||||||
trackedDownload.State = TrackedDownloadState.DownloadFailed;
|
trackedDownload.State = TrackedDownloadState.DownloadFailed;
|
||||||
|
|
||||||
var failedItems = GetHistoryItems(failedHistory, trackedDownload.DownloadItem.DownloadClientId);
|
|
||||||
|
|
||||||
if (failedItems.Any())
|
|
||||||
{
|
|
||||||
UpdateStatusMessage(trackedDownload, LogLevel.Debug, "Already added to history as failed.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PublishDownloadFailedEvent(grabbedItems, trackedDownload.DownloadItem.Message);
|
PublishDownloadFailedEvent(grabbedItems, trackedDownload.DownloadItem.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue