From fddf2d1fc8b600d8f82b2dbfd2376b0538c3cc83 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 6 Jan 2021 21:57:52 -0800 Subject: [PATCH] Better task interval fetching --- src/NzbDrone.Core/Jobs/TaskManager.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core/Jobs/TaskManager.cs b/src/NzbDrone.Core/Jobs/TaskManager.cs index 5ac2bed2f..7b862bf4a 100644 --- a/src/NzbDrone.Core/Jobs/TaskManager.cs +++ b/src/NzbDrone.Core/Jobs/TaskManager.cs @@ -120,9 +120,19 @@ namespace NzbDrone.Core.Jobs private int GetBackupInterval() { - var interval = _configService.BackupInterval; + var intervalMinutes = _configService.BackupInterval; - return interval * 60 * 24; + if (intervalMinutes < 1) + { + intervalMinutes = 1; + } + + if (intervalMinutes > 7) + { + intervalMinutes = 7; + } + + return intervalMinutes * 60 * 24; } private int GetRssSyncInterval() @@ -156,10 +166,10 @@ namespace NzbDrone.Core.Jobs public void HandleAsync(ConfigSavedEvent message) { var rss = _scheduledTaskRepository.GetDefinition(typeof(RssSyncCommand)); - rss.Interval = _configService.RssSyncInterval; + rss.Interval = GetRssSyncInterval(); var backup = _scheduledTaskRepository.GetDefinition(typeof(BackupCommand)); - backup.Interval = _configService.BackupInterval * 60 * 24; + backup.Interval = GetBackupInterval(); _scheduledTaskRepository.UpdateMany(new List{ rss, backup }); }