mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-24 22:55:21 -04:00
Fixed: Remove seeded downloads if they've finished seeding after import
This commit is contained in:
@@ -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)
|
||||
public void Handle(DownloadCanBeRemovedEvent message)
|
||||
{
|
||||
var trackedDownload = message.TrackedDownload;
|
||||
|
||||
if (trackedDownload == null || !trackedDownload.DownloadItem.CanBeRemoved || _configService.RemoveFailedDownloads == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveFromDownloadClient(trackedDownload);
|
||||
// Already verified that it can be removed, just needs to be removed
|
||||
RemoveFromDownloadClient(message.TrackedDownload);
|
||||
}
|
||||
|
||||
private void RemoveFromDownloadClient(TrackedDownload trackedDownload)
|
||||
|
||||
Reference in New Issue
Block a user