From f411903e90224c976f0b7e61406450374c19e408 Mon Sep 17 00:00:00 2001 From: Steven Crouchman Date: Thu, 2 May 2019 11:51:21 +0100 Subject: [PATCH] New: Allow CheckForFinishedDownloadInterval to be set from the UI (#3233) * Adding CheckForFinishedDownloadInterval to config service Changed TaskManager to use a configurable interval for CheckForFinishedDownloadCommand * Adding new CheckForFinishedDownloadInterval to UI Fixes #840 --- .../Config/DownloadClientConfigResource.cs | 4 +++- src/NzbDrone.Core/Configuration/ConfigService.cs | 7 +++++++ src/NzbDrone.Core/Configuration/IConfigService.cs | 1 + src/NzbDrone.Core/Jobs/TaskManager.cs | 12 ++++++++++-- .../DownloadHandlingViewTemplate.hbs | 12 ++++++++++++ 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs b/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs index b34febd7b..4d3a08add 100644 --- a/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs +++ b/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs @@ -1,4 +1,4 @@ -using NzbDrone.Api.REST; +using NzbDrone.Api.REST; using NzbDrone.Core.Configuration; namespace NzbDrone.Api.Config @@ -11,6 +11,7 @@ namespace NzbDrone.Api.Config public bool EnableCompletedDownloadHandling { get; set; } public bool RemoveCompletedDownloads { get; set; } + public int CheckForFinishedDownloadInterval { get; set; } public bool AutoRedownloadFailed { get; set; } public bool RemoveFailedDownloads { get; set; } @@ -28,6 +29,7 @@ namespace NzbDrone.Api.Config EnableCompletedDownloadHandling = model.EnableCompletedDownloadHandling, RemoveCompletedDownloads = model.RemoveCompletedDownloads, + CheckForFinishedDownloadInterval = model.CheckForFinishedDownloadInterval, AutoRedownloadFailed = model.AutoRedownloadFailed, RemoveFailedDownloads = model.RemoveFailedDownloads diff --git a/src/NzbDrone.Core/Configuration/ConfigService.cs b/src/NzbDrone.Core/Configuration/ConfigService.cs index 9b1ca4820..e107a107a 100644 --- a/src/NzbDrone.Core/Configuration/ConfigService.cs +++ b/src/NzbDrone.Core/Configuration/ConfigService.cs @@ -273,6 +273,13 @@ namespace NzbDrone.Core.Configuration set { SetValue("DownloadedMoviesScanInterval", value); } } + public int CheckForFinishedDownloadInterval + { + get { return GetValueInt("CheckForFinishedDownloadInterval", 1); } + + set { SetValue("CheckForFinishedDownloadInterval", value); } + } + public int DownloadClientHistoryLimit { get { return GetValueInt("DownloadClientHistoryLimit", 30); } diff --git a/src/NzbDrone.Core/Configuration/IConfigService.cs b/src/NzbDrone.Core/Configuration/IConfigService.cs index 790a1a56a..0b8b2e274 100644 --- a/src/NzbDrone.Core/Configuration/IConfigService.cs +++ b/src/NzbDrone.Core/Configuration/IConfigService.cs @@ -16,6 +16,7 @@ namespace NzbDrone.Core.Configuration string DownloadClientWorkingFolders { get; set; } int DownloadedMoviesScanInterval { get; set; } int DownloadClientHistoryLimit { get; set; } + int CheckForFinishedDownloadInterval { get; set; } //Completed/Failed Download Handling (Download client) bool EnableCompletedDownloadHandling { get; set; } diff --git a/src/NzbDrone.Core/Jobs/TaskManager.cs b/src/NzbDrone.Core/Jobs/TaskManager.cs index 7133803ca..e8e0ce4dc 100644 --- a/src/NzbDrone.Core/Jobs/TaskManager.cs +++ b/src/NzbDrone.Core/Jobs/TaskManager.cs @@ -71,7 +71,6 @@ namespace NzbDrone.Core.Jobs var defaultTasks = new[] { - new ScheduledTask{ Interval = 1, TypeName = typeof(CheckForFinishedDownloadCommand).FullName}, new ScheduledTask{ Interval = 1*60, TypeName = typeof(PreDBSyncCommand).FullName}, new ScheduledTask{ Interval = 5, TypeName = typeof(MessagingCleanupCommand).FullName}, new ScheduledTask{ Interval = updateInterval, TypeName = typeof(ApplicationUpdateCommand).FullName}, @@ -98,6 +97,12 @@ namespace NzbDrone.Core.Jobs Interval = _configService.DownloadedMoviesScanInterval, TypeName = typeof(DownloadedMoviesScanCommand).FullName }, + + new ScheduledTask + { + Interval = Math.Max(_configService.CheckForFinishedDownloadInterval, 1), + TypeName = typeof(CheckForFinishedDownloadCommand).FullName + }, }; var currentTasks = _scheduledTaskRepository.All().ToList(); @@ -184,7 +189,10 @@ namespace NzbDrone.Core.Jobs var netImport = _scheduledTaskRepository.GetDefinition(typeof(NetImportSyncCommand)); netImport.Interval = _configService.NetImportSyncInterval; - _scheduledTaskRepository.UpdateMany(new List { rss, downloadedMovies, netImport }); + var checkForFinishedDownloads = _scheduledTaskRepository.GetDefinition(typeof(CheckForFinishedDownloadCommand)); + checkForFinishedDownloads.Interval = _configService.CheckForFinishedDownloadInterval; + + _scheduledTaskRepository.UpdateMany(new List { rss, downloadedMovies, netImport, checkForFinishedDownloads }); } } } diff --git a/src/UI/Settings/DownloadClient/DownloadHandling/DownloadHandlingViewTemplate.hbs b/src/UI/Settings/DownloadClient/DownloadHandling/DownloadHandlingViewTemplate.hbs index b268197f9..43352b946 100644 --- a/src/UI/Settings/DownloadClient/DownloadHandling/DownloadHandlingViewTemplate.hbs +++ b/src/UI/Settings/DownloadClient/DownloadHandling/DownloadHandlingViewTemplate.hbs @@ -43,6 +43,18 @@ + +
+ + +
+ +
+ +
+ +
+