diff --git a/src/NzbDrone.Core/Download/DownloadCanBeRemovedEvent.cs b/src/NzbDrone.Core/Download/DownloadCanBeRemovedEvent.cs index b852ee63d..99cb3e706 100644 --- a/src/NzbDrone.Core/Download/DownloadCanBeRemovedEvent.cs +++ b/src/NzbDrone.Core/Download/DownloadCanBeRemovedEvent.cs @@ -1,4 +1,4 @@ -using NzbDrone.Common.Messaging; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Download.TrackedDownloads; namespace NzbDrone.Core.Download diff --git a/src/NzbDrone.Core/Download/DownloadClientItem.cs b/src/NzbDrone.Core/Download/DownloadClientItem.cs index 88b04e0fe..aa44a3acf 100644 --- a/src/NzbDrone.Core/Download/DownloadClientItem.cs +++ b/src/NzbDrone.Core/Download/DownloadClientItem.cs @@ -6,7 +6,7 @@ using NzbDrone.Core.ThingiProvider; namespace NzbDrone.Core.Download { - [DebuggerDisplay("{DownloadClientName}:{Title}")] + [DebuggerDisplay("{DownloadClientInfo?.Name}:{Title}")] public class DownloadClientItem { public DownloadClientItemClientInfo DownloadClientInfo { get; set; } diff --git a/src/NzbDrone.Core/Download/DownloadProcessingService.cs b/src/NzbDrone.Core/Download/DownloadProcessingService.cs index 97848add4..64890fdf0 100644 --- a/src/NzbDrone.Core/Download/DownloadProcessingService.cs +++ b/src/NzbDrone.Core/Download/DownloadProcessingService.cs @@ -32,9 +32,18 @@ namespace NzbDrone.Core.Download _logger = logger; } + private void RemoveCompletedDownloads(List trackedDownloads) + { + foreach (var trackedDownload in trackedDownloads.Where(c => c.DownloadItem.CanBeRemoved && c.State == TrackedDownloadState.Imported)) + { + _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload)); + } + } + public void Execute(ProcessMonitoredDownloadsCommand message) { var enableCompletedDownloadHandling = _configService.EnableCompletedDownloadHandling; + var removeCompletedDownloads = _configService.RemoveCompletedDownloads; var trackedDownloads = _trackedDownloadService.GetTrackedDownloads() .Where(t => t.IsTrackable) .ToList(); @@ -46,10 +55,20 @@ namespace NzbDrone.Core.Download if (trackedDownload.State == TrackedDownloadState.DownloadFailedPending) { _failedDownloadService.ProcessFailed(trackedDownload); + continue; } else if (enableCompletedDownloadHandling && trackedDownload.State == TrackedDownloadState.ImportPending) { _completedDownloadService.Import(trackedDownload); + continue; + } + + if (removeCompletedDownloads && + trackedDownload.DownloadItem.Removed && + trackedDownload.DownloadItem.CanBeRemoved && + trackedDownload.State == TrackedDownloadState.Imported) + { + _eventAggregator.PublishEvent(new DownloadCanBeRemovedEvent(trackedDownload)); } } catch (Exception e)