1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

Fixed: Manually marking a grabbed release failed will now mark all episodes in that release failed instead of only one.

This commit is contained in:
Taloth Saldono 2014-07-21 22:56:13 +02:00
parent 74a38415cf
commit 4b53cc7e52
2 changed files with 37 additions and 2 deletions

View File

@ -9,6 +9,7 @@
using NzbDrone.Core.History;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.Download
{
@ -379,6 +380,30 @@ public void should_not_process_if_age_is_less_than_grace_period()
Subject.Execute(new CheckForFinishedDownloadCommand());
VerifyNoFailedDownloads();
ExceptionVerification.IgnoreWarns();
}
[Test]
public void should_manual_mark_all_episodes_of_release_as_failed()
{
var historyFailed = Builder<History.History>.CreateListOfSize(2)
.All()
.With(v => v.EventType == HistoryEventType.Grabbed)
.Do(v => v.Data.Add("downloadClient", "SabnzbdClient"))
.Do(v => v.Data.Add("downloadClientId", "test"))
.Build()
.ToList();
GivenGrabbedHistory(historyFailed);
Mocker.GetMock<IHistoryService>()
.Setup(s => s.Get(It.IsAny<Int32>()))
.Returns<Int32>(i => historyFailed.FirstOrDefault(v => v.Id == i));
Subject.MarkAsFailed(1);
VerifyFailedDownloads(2);
}
}
}

View File

@ -35,14 +35,24 @@ public FailedDownloadService(IHistoryService historyService,
_logger = logger;
}
public void MarkAsFailed(TrackedDownload trackedDownload, History.History grabbedHistory)
public void MarkAsFailed(TrackedDownload trackedDownload, History.History history)
{
if (trackedDownload != null && trackedDownload.State == TrackedDownloadState.Downloading)
{
trackedDownload.State = TrackedDownloadState.DownloadFailed;
}
PublishDownloadFailedEvent(new List<History.History> { grabbedHistory }, "Manually marked as failed");
var downloadClientId = history.Data.GetValueOrDefault(DownloadTrackingService.DOWNLOAD_CLIENT_ID);
if (downloadClientId.IsNullOrWhiteSpace())
{
PublishDownloadFailedEvent(new List<History.History> { history }, "Manually marked as failed");
}
else
{
var grabbedHistory = GetHistoryItems(_historyService.Grabbed(), downloadClientId);
PublishDownloadFailedEvent(grabbedHistory, "Manually marked as failed");
}
}
public void CheckForFailedItem(IDownloadClient downloadClient, TrackedDownload trackedDownload, List<History.History> grabbedHistory, List<History.History> failedHistory)