Fixed: Remove failed downloads from download client (when enabled)

pull/2/head
Mark McDowall 10 years ago
parent e43f251f74
commit 2306815992

@ -68,7 +68,6 @@ namespace NzbDrone.Core.Test.Download
AssertDownloadNotFailed();
}
[Test]
public void should_mark_failed_if_encrypted()
{
@ -79,7 +78,6 @@ namespace NzbDrone.Core.Test.Download
AssertDownloadFailed();
}
[Test]
public void should_mark_failed_if_download_item_is_failed()
{
@ -90,6 +88,18 @@ namespace NzbDrone.Core.Test.Download
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 @@ namespace NzbDrone.Core.Download
{
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 @@ namespace NzbDrone.Core.Download
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 @@ namespace NzbDrone.Core.Download
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 @@ namespace NzbDrone.Core.Download
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 @@ namespace NzbDrone.Core.Download
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 @@ namespace NzbDrone.Core.Download.TrackedDownloads
return TrackedDownloadStage.Downloading;
}
}
}
}
}

Loading…
Cancel
Save