mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Fixed: Remove failed downloads from download client (when enabled)
This commit is contained in:
parent
e43f251f74
commit
2306815992
@ -68,7 +68,6 @@ public void should_not_fail_if_matching_history_is_not_found()
|
|||||||
AssertDownloadNotFailed();
|
AssertDownloadNotFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_mark_failed_if_encrypted()
|
public void should_mark_failed_if_encrypted()
|
||||||
{
|
{
|
||||||
@ -79,7 +78,6 @@ public void should_mark_failed_if_encrypted()
|
|||||||
AssertDownloadFailed();
|
AssertDownloadFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_mark_failed_if_download_item_is_failed()
|
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();
|
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()
|
private void AssertDownloadNotFailed()
|
||||||
{
|
{
|
||||||
|
@ -22,17 +22,14 @@ public class DownloadEventHub : IHandle<DownloadFailedEvent>,
|
|||||||
{
|
{
|
||||||
private readonly IConfigService _configService;
|
private readonly IConfigService _configService;
|
||||||
private readonly IProvideDownloadClient _downloadClientProvider;
|
private readonly IProvideDownloadClient _downloadClientProvider;
|
||||||
private readonly ITrackedDownloadService _trackedDownloadService;
|
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public DownloadEventHub(IConfigService configService,
|
public DownloadEventHub(IConfigService configService,
|
||||||
IProvideDownloadClient downloadClientProvider,
|
IProvideDownloadClient downloadClientProvider,
|
||||||
ITrackedDownloadService trackedDownloadService,
|
|
||||||
Logger logger)
|
Logger logger)
|
||||||
{
|
{
|
||||||
_configService = configService;
|
_configService = configService;
|
||||||
_downloadClientProvider = downloadClientProvider;
|
_downloadClientProvider = downloadClientProvider;
|
||||||
_trackedDownloadService = trackedDownloadService;
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,8 +45,7 @@ public void Handle(DownloadCompletedEvent message)
|
|||||||
|
|
||||||
public void Handle(DownloadFailedEvent 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)
|
if (trackedDownload == null || trackedDownload.DownloadItem.IsReadOnly || _configService.RemoveFailedDownloads == false)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NzbDrone.Common.Messaging;
|
using NzbDrone.Common.Messaging;
|
||||||
|
using NzbDrone.Core.Download.TrackedDownloads;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Download
|
namespace NzbDrone.Core.Download
|
||||||
@ -20,5 +21,6 @@ public DownloadFailedEvent()
|
|||||||
public String DownloadId { get; set; }
|
public String DownloadId { get; set; }
|
||||||
public String Message { get; set; }
|
public String Message { get; set; }
|
||||||
public Dictionary<string, string> Data { 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)
|
if (trackedDownload.DownloadItem.IsEncrypted)
|
||||||
{
|
{
|
||||||
trackedDownload.State = TrackedDownloadStage.DownloadFailed;
|
trackedDownload.State = TrackedDownloadStage.DownloadFailed;
|
||||||
PublishDownloadFailedEvent(grabbedItems, "Encrypted download detected");
|
PublishDownloadFailedEvent(grabbedItems, "Encrypted download detected", trackedDownload);
|
||||||
}
|
}
|
||||||
else if (trackedDownload.DownloadItem.Status == DownloadItemStatus.Failed)
|
else if (trackedDownload.DownloadItem.Status == DownloadItemStatus.Failed)
|
||||||
{
|
{
|
||||||
trackedDownload.State = TrackedDownloadStage.DownloadFailed;
|
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();
|
var historyItem = historyItems.First();
|
||||||
|
|
||||||
@ -77,12 +77,11 @@ private void PublishDownloadFailedEvent(List<History.History> historyItems, stri
|
|||||||
DownloadClient = historyItem.Data.GetValueOrDefault(History.History.DOWNLOAD_CLIENT),
|
DownloadClient = historyItem.Data.GetValueOrDefault(History.History.DOWNLOAD_CLIENT),
|
||||||
DownloadId = historyItem.DownloadId,
|
DownloadId = historyItem.DownloadId,
|
||||||
Message = message,
|
Message = message,
|
||||||
Data = historyItem.Data
|
Data = historyItem.Data,
|
||||||
|
TrackedDownload = trackedDownload
|
||||||
};
|
};
|
||||||
|
|
||||||
_eventAggregator.PublishEvent(downloadFailedEvent);
|
_eventAggregator.PublishEvent(downloadFailedEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,5 @@ private static TrackedDownloadStage GetStateFromHistory(HistoryEventType eventTy
|
|||||||
return TrackedDownloadStage.Downloading;
|
return TrackedDownloadStage.Downloading;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user