Better task interval fetching

This commit is contained in:
Mark McDowall 2021-01-06 21:57:52 -08:00
parent 6d44d6c1b7
commit fddf2d1fc8
1 changed files with 14 additions and 4 deletions

View File

@ -120,9 +120,19 @@ namespace NzbDrone.Core.Jobs
private int GetBackupInterval() 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() private int GetRssSyncInterval()
@ -156,10 +166,10 @@ namespace NzbDrone.Core.Jobs
public void HandleAsync(ConfigSavedEvent message) public void HandleAsync(ConfigSavedEvent message)
{ {
var rss = _scheduledTaskRepository.GetDefinition(typeof(RssSyncCommand)); var rss = _scheduledTaskRepository.GetDefinition(typeof(RssSyncCommand));
rss.Interval = _configService.RssSyncInterval; rss.Interval = GetRssSyncInterval();
var backup = _scheduledTaskRepository.GetDefinition(typeof(BackupCommand)); var backup = _scheduledTaskRepository.GetDefinition(typeof(BackupCommand));
backup.Interval = _configService.BackupInterval * 60 * 24; backup.Interval = GetBackupInterval();
_scheduledTaskRepository.UpdateMany(new List<ScheduledTask>{ rss, backup }); _scheduledTaskRepository.UpdateMany(new List<ScheduledTask>{ rss, backup });
} }