diff --git a/src/NzbDrone.Core.Test/Download/FailedDownloadServiceFixture.cs b/src/NzbDrone.Core.Test/Download/FailedDownloadServiceFixture.cs index 44e563718..f293bcdbd 100644 --- a/src/NzbDrone.Core.Test/Download/FailedDownloadServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Download/FailedDownloadServiceFixture.cs @@ -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.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() + .Setup(s => s.Get(It.IsAny())) + .Returns(i => historyFailed.FirstOrDefault(v => v.Id == i)); + + Subject.MarkAsFailed(1); + + VerifyFailedDownloads(2); } } } diff --git a/src/NzbDrone.Core/Download/FailedDownloadService.cs b/src/NzbDrone.Core/Download/FailedDownloadService.cs index b0137c663..c104897bd 100644 --- a/src/NzbDrone.Core/Download/FailedDownloadService.cs +++ b/src/NzbDrone.Core/Download/FailedDownloadService.cs @@ -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 { grabbedHistory }, "Manually marked as failed"); + var downloadClientId = history.Data.GetValueOrDefault(DownloadTrackingService.DOWNLOAD_CLIENT_ID); + if (downloadClientId.IsNullOrWhiteSpace()) + { + PublishDownloadFailedEvent(new List { 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 grabbedHistory, List failedHistory)