mirror of
https://github.com/Radarr/Radarr
synced 2024-12-27 02:09:59 +00:00
Fixed: Remove failed downloads from download client (when enabled)
This commit is contained in:
parent
e43f251f74
commit
2306815992
5 changed files with 21 additions and 15 deletions
|
@ -68,7 +68,6 @@ public void should_not_fail_if_matching_history_is_not_found()
|
|||
AssertDownloadNotFailed();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_mark_failed_if_encrypted()
|
||||
{
|
||||
|
@ -79,7 +78,6 @@ public void should_mark_failed_if_encrypted()
|
|||
AssertDownloadFailed();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_mark_failed_if_download_item_is_failed()
|
||||
{
|
||||
|
@ -90,6 +88,18 @@ public void should_mark_failed_if_download_item_is_failed()
|
|||
AssertDownloadFailed();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_include_tracked_download_in_message()
|
||||
{
|
||||
_trackedDownload.DownloadItem.Status = DownloadItemStatus.Failed;
|
||||
|
||||
Subject.Process(_trackedDownload);
|
||||
|
||||
Mocker.GetMock<IEventAggregator>()
|
||||
.Verify(v => v.PublishEvent(It.Is<DownloadFailedEvent>(c => c.TrackedDownload != null)), Times.Once());
|
||||
|
||||
AssertDownloadFailed();
|
||||
}
|
||||
|
||||
private void AssertDownloadNotFailed()
|
||||
{
|
||||
|
|
|
@ -22,17 +22,14 @@ public class DownloadEventHub : IHandle<DownloadFailedEvent>,
|
|||
{
|
||||
private readonly IConfigService _configService;
|
||||
private readonly IProvideDownloadClient _downloadClientProvider;
|
||||
private readonly ITrackedDownloadService _trackedDownloadService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public DownloadEventHub(IConfigService configService,
|
||||
IProvideDownloadClient downloadClientProvider,
|
||||
ITrackedDownloadService trackedDownloadService,
|
||||
Logger logger)
|
||||
{
|
||||
_configService = configService;
|
||||
_downloadClientProvider = downloadClientProvider;
|
||||
_trackedDownloadService = trackedDownloadService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
@ -48,8 +45,7 @@ public void Handle(DownloadCompletedEvent message)
|
|||
|
||||
public void Handle(DownloadFailedEvent message)
|
||||
{
|
||||
var trackedDownload = _trackedDownloadService.Find(message.DownloadId);
|
||||
|
||||
var trackedDownload = message.TrackedDownload;
|
||||
|
||||
if (trackedDownload == null || trackedDownload.DownloadItem.IsReadOnly || _configService.RemoveFailedDownloads == false)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Download.TrackedDownloads;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
|
@ -20,5 +21,6 @@ public DownloadFailedEvent()
|
|||
public String DownloadId { get; set; }
|
||||
public String Message { get; set; }
|
||||
public Dictionary<string, string> Data { get; set; }
|
||||
public TrackedDownload TrackedDownload { get; set; }
|
||||
}
|
||||
}
|
|
@ -55,16 +55,16 @@ public void Process(TrackedDownload trackedDownload)
|
|||
if (trackedDownload.DownloadItem.IsEncrypted)
|
||||
{
|
||||
trackedDownload.State = TrackedDownloadStage.DownloadFailed;
|
||||
PublishDownloadFailedEvent(grabbedItems, "Encrypted download detected");
|
||||
PublishDownloadFailedEvent(grabbedItems, "Encrypted download detected", trackedDownload);
|
||||
}
|
||||
else if (trackedDownload.DownloadItem.Status == DownloadItemStatus.Failed)
|
||||
{
|
||||
trackedDownload.State = TrackedDownloadStage.DownloadFailed;
|
||||
PublishDownloadFailedEvent(grabbedItems, trackedDownload.DownloadItem.Message);
|
||||
PublishDownloadFailedEvent(grabbedItems, trackedDownload.DownloadItem.Message, trackedDownload);
|
||||
}
|
||||
}
|
||||
|
||||
private void PublishDownloadFailedEvent(List<History.History> historyItems, string message)
|
||||
private void PublishDownloadFailedEvent(List<History.History> historyItems, string message, TrackedDownload trackedDownload = null)
|
||||
{
|
||||
var historyItem = historyItems.First();
|
||||
|
||||
|
@ -77,12 +77,11 @@ private void PublishDownloadFailedEvent(List<History.History> historyItems, stri
|
|||
DownloadClient = historyItem.Data.GetValueOrDefault(History.History.DOWNLOAD_CLIENT),
|
||||
DownloadId = historyItem.DownloadId,
|
||||
Message = message,
|
||||
Data = historyItem.Data
|
||||
Data = historyItem.Data,
|
||||
TrackedDownload = trackedDownload
|
||||
};
|
||||
|
||||
_eventAggregator.PublishEvent(downloadFailedEvent);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,6 +95,5 @@ private static TrackedDownloadStage GetStateFromHistory(HistoryEventType eventTy
|
|||
return TrackedDownloadStage.Downloading;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue