mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-25 15:22:42 +00:00
Fixed: Imported downloads not being removed when seeding goals are met
Closes #1400
This commit is contained in:
parent
1d58b33ac6
commit
e836b795de
1 changed files with 14 additions and 14 deletions
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.Download.TrackedDownloads;
|
using NzbDrone.Core.Download.TrackedDownloads;
|
||||||
|
@ -31,9 +32,13 @@ public DownloadProcessingService(IConfigService configService,
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveCompletedDownloads(List<TrackedDownload> trackedDownloads)
|
private void RemoveCompletedDownloads()
|
||||||
{
|
{
|
||||||
foreach (var trackedDownload in trackedDownloads.Where(c => c.DownloadItem.CanBeRemoved && c.State == TrackedDownloadState.Imported))
|
var trackedDownloads = _trackedDownloadService.GetTrackedDownloads()
|
||||||
|
.Where(t => !t.DownloadItem.Removed && t.DownloadItem.CanBeRemoved && t.State == TrackedDownloadState.Imported)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach (var trackedDownload in trackedDownloads)
|
||||||
{
|
{
|
||||||
_eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload));
|
_eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload));
|
||||||
}
|
}
|
||||||
|
@ -54,21 +59,10 @@ public void Execute(ProcessMonitoredDownloadsCommand message)
|
||||||
if (trackedDownload.State == TrackedDownloadState.DownloadFailedPending)
|
if (trackedDownload.State == TrackedDownloadState.DownloadFailedPending)
|
||||||
{
|
{
|
||||||
_failedDownloadService.ProcessFailed(trackedDownload);
|
_failedDownloadService.ProcessFailed(trackedDownload);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
else if (enableCompletedDownloadHandling && trackedDownload.State == TrackedDownloadState.ImportPending)
|
||||||
if (enableCompletedDownloadHandling && trackedDownload.State == TrackedDownloadState.ImportPending)
|
|
||||||
{
|
{
|
||||||
_completedDownloadService.Import(trackedDownload);
|
_completedDownloadService.Import(trackedDownload);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (removeCompletedDownloads &&
|
|
||||||
trackedDownload.DownloadItem.Removed &&
|
|
||||||
trackedDownload.DownloadItem.CanBeRemoved &&
|
|
||||||
trackedDownload.State == TrackedDownloadState.Imported)
|
|
||||||
{
|
|
||||||
_eventAggregator.PublishEvent(new DownloadCanBeRemovedEvent(trackedDownload));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -77,6 +71,12 @@ public void Execute(ProcessMonitoredDownloadsCommand message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Imported downloads are no longer trackable so process them after processing trackable downloads
|
||||||
|
if (removeCompletedDownloads)
|
||||||
|
{
|
||||||
|
RemoveCompletedDownloads();
|
||||||
|
}
|
||||||
|
|
||||||
_eventAggregator.PublishEvent(new DownloadsProcessedEvent());
|
_eventAggregator.PublishEvent(new DownloadsProcessedEvent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue