From 19dceb35fae9838bb4444fe9a0f3826d82223616 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 30 Jan 2021 22:04:15 -0500 Subject: [PATCH] Better task interval fetching Fixes #5700 Co-Authored-By: Mark McDowall --- src/NzbDrone.Core/Jobs/TaskManager.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core/Jobs/TaskManager.cs b/src/NzbDrone.Core/Jobs/TaskManager.cs index c49d5899f6..29d494517a 100644 --- a/src/NzbDrone.Core/Jobs/TaskManager.cs +++ b/src/NzbDrone.Core/Jobs/TaskManager.cs @@ -123,9 +123,19 @@ public void Handle(ApplicationStartedEvent message) private int GetBackupInterval() { - var interval = _configService.BackupInterval; + var intervalDays = _configService.BackupInterval; - return interval * 60 * 24; + if (intervalDays < 1) + { + intervalDays = 1; + } + + if (intervalDays > 7) + { + intervalDays = 7; + } + + return intervalDays * 60 * 24; } private int GetRssSyncInterval() @@ -167,7 +177,7 @@ public void Handle(CommandExecutedEvent message) public void HandleAsync(ConfigSavedEvent message) { var rss = _scheduledTaskRepository.GetDefinition(typeof(RssSyncCommand)); - rss.Interval = _configService.RssSyncInterval; + rss.Interval = GetRssSyncInterval(); var importList = _scheduledTaskRepository.GetDefinition(typeof(ImportListSyncCommand)); importList.Interval = GetImportListSyncInterval();