From 16dd5b621ead55fc9ea8289fb2547b9daa9ce7de Mon Sep 17 00:00:00 2001 From: markus101 Date: Tue, 4 Feb 2014 21:52:53 -0800 Subject: [PATCH] ScheduledTasks won't run immediately after first start --- src/NzbDrone.Core/Jobs/TaskManager.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Jobs/TaskManager.cs b/src/NzbDrone.Core/Jobs/TaskManager.cs index 0470c17ee..e40e08f8e 100644 --- a/src/NzbDrone.Core/Jobs/TaskManager.cs +++ b/src/NzbDrone.Core/Jobs/TaskManager.cs @@ -57,7 +57,7 @@ public void Handle(ApplicationStartedEvent message) new ScheduledTask{ Interval = 24*60, TypeName = typeof(HousekeepingCommand).FullName}, }; - var currentTasks = _scheduledTaskRepository.All(); + var currentTasks = _scheduledTaskRepository.All().ToList(); _logger.Debug("Initializing jobs. Available: {0} Existing:{1}", defaultTasks.Count(), currentTasks.Count()); @@ -76,6 +76,11 @@ public void Handle(ApplicationStartedEvent message) currentDefinition.Interval = defaultTask.Interval; + if (currentDefinition.Id == 0) + { + currentDefinition.LastExecution = DateTime.UtcNow; + } + _scheduledTaskRepository.Upsert(currentDefinition); } }