|
|
|
@ -1,24 +1,14 @@
|
|
|
|
|
using System;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Common.Messaging;
|
|
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
|
using NzbDrone.Core.Download.TrackedDownloads;
|
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Download
|
|
|
|
|
{
|
|
|
|
|
public class DownloadCompletedEvent : IEvent
|
|
|
|
|
{
|
|
|
|
|
public TrackedDownload TrackedDownload { get; private set; }
|
|
|
|
|
|
|
|
|
|
public DownloadCompletedEvent(TrackedDownload trackedDownload)
|
|
|
|
|
{
|
|
|
|
|
TrackedDownload = trackedDownload;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DownloadEventHub : IHandle<DownloadFailedEvent>,
|
|
|
|
|
IHandle<DownloadCompletedEvent>
|
|
|
|
|
IHandle<DownloadCompletedEvent>,
|
|
|
|
|
IHandle<DownloadCanBeRemovedEvent>
|
|
|
|
|
{
|
|
|
|
|
private readonly IConfigService _configService;
|
|
|
|
|
private readonly IProvideDownloadClient _downloadClientProvider;
|
|
|
|
@ -33,6 +23,18 @@ namespace NzbDrone.Core.Download
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Handle(DownloadFailedEvent message)
|
|
|
|
|
{
|
|
|
|
|
var trackedDownload = message.TrackedDownload;
|
|
|
|
|
|
|
|
|
|
if (trackedDownload == null || !trackedDownload.DownloadItem.CanBeRemoved || _configService.RemoveFailedDownloads == false)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RemoveFromDownloadClient(trackedDownload);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Handle(DownloadCompletedEvent message)
|
|
|
|
|
{
|
|
|
|
|
if (_configService.RemoveCompletedDownloads &&
|
|
|
|
@ -48,16 +50,10 @@ namespace NzbDrone.Core.Download
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Handle(DownloadFailedEvent message)
|
|
|
|
|
{
|
|
|
|
|
var trackedDownload = message.TrackedDownload;
|
|
|
|
|
|
|
|
|
|
if (trackedDownload == null || !trackedDownload.DownloadItem.CanBeRemoved || _configService.RemoveFailedDownloads == false)
|
|
|
|
|
public void Handle(DownloadCanBeRemovedEvent message)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RemoveFromDownloadClient(trackedDownload);
|
|
|
|
|
// Already verified that it can be removed, just needs to be removed
|
|
|
|
|
RemoveFromDownloadClient(message.TrackedDownload);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RemoveFromDownloadClient(TrackedDownload trackedDownload)
|
|
|
|
|