|
|
@ -33,9 +33,13 @@ namespace NzbDrone.Core.Download
|
|
|
|
_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));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -56,21 +60,10 @@ namespace NzbDrone.Core.Download
|
|
|
|
if (trackedDownload.State == TrackedDownloadState.FailedPending)
|
|
|
|
if (trackedDownload.State == TrackedDownloadState.FailedPending)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_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)
|
|
|
@ -79,6 +72,12 @@ namespace NzbDrone.Core.Download
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Imported downloads are no longer trackable so process them after processing trackable downloads
|
|
|
|
|
|
|
|
if (removeCompletedDownloads)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
RemoveCompletedDownloads();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_eventAggregator.PublishEvent(new DownloadsProcessedEvent());
|
|
|
|
_eventAggregator.PublishEvent(new DownloadsProcessedEvent());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|