From 68d1c421ba8706f9645aa0872a08dfc43c7c1647 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 15 Dec 2013 20:10:03 -0800 Subject: [PATCH] Fixed: Refresh Xem mapped series list every 12 hours, instead of on startup only --- .../Xem/RefreshXemCacheCommand.cs | 8 ++++ .../DataAugmentation/Xem/XemService.cs | 41 +++++++++++-------- src/NzbDrone.Core/Jobs/TaskManager.cs | 10 +++-- 3 files changed, 37 insertions(+), 22 deletions(-) create mode 100644 src/NzbDrone.Core/DataAugmentation/Xem/RefreshXemCacheCommand.cs diff --git a/src/NzbDrone.Core/DataAugmentation/Xem/RefreshXemCacheCommand.cs b/src/NzbDrone.Core/DataAugmentation/Xem/RefreshXemCacheCommand.cs new file mode 100644 index 000000000..67dd09657 --- /dev/null +++ b/src/NzbDrone.Core/DataAugmentation/Xem/RefreshXemCacheCommand.cs @@ -0,0 +1,8 @@ +using NzbDrone.Core.Messaging.Commands; + +namespace NzbDrone.Core.DataAugmentation.Xem +{ + public class RefreshXemCacheCommand : Command + { + } +} diff --git a/src/NzbDrone.Core/DataAugmentation/Xem/XemService.cs b/src/NzbDrone.Core/DataAugmentation/Xem/XemService.cs index f8dfed427..4dded7395 100644 --- a/src/NzbDrone.Core/DataAugmentation/Xem/XemService.cs +++ b/src/NzbDrone.Core/DataAugmentation/Xem/XemService.cs @@ -2,13 +2,14 @@ using System.Linq; using NLog; using NzbDrone.Common.Cache; +using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Tv; using NzbDrone.Core.Tv.Events; namespace NzbDrone.Core.DataAugmentation.Xem { - public class XemService : IHandle + public class XemService : IHandle, IExecute { private readonly IEpisodeService _episodeService; private readonly IXemProxy _xemProxy; @@ -28,23 +29,6 @@ namespace NzbDrone.Core.DataAugmentation.Xem _cache = cacheManger.GetCache(GetType()); } - - public void Handle(SeriesUpdatedEvent message) - { - if (_cache.Count == 0) - { - RefreshCache(); - } - - if (!_cache.Find(message.Series.TvdbId.ToString())) - { - _logger.Trace("Scene numbering is not available for {0} [{1}]", message.Series.Title, message.Series.TvdbId); - return; - } - - PerformUpdate(message.Series); - } - private void PerformUpdate(Series series) { _logger.Trace("Updating scene numbering mapping for: {0}", series); @@ -109,5 +93,26 @@ namespace NzbDrone.Core.DataAugmentation.Xem _cache.Set(id.ToString(), true, TimeSpan.FromHours(1)); } } + + public void Handle(SeriesUpdatedEvent message) + { + if (_cache.Count == 0) + { + RefreshCache(); + } + + if (!_cache.Find(message.Series.TvdbId.ToString())) + { + _logger.Trace("Scene numbering is not available for {0} [{1}]", message.Series.Title, message.Series.TvdbId); + return; + } + + PerformUpdate(message.Series); + } + + public void Execute(RefreshXemCacheCommand message) + { + RefreshCache(); + } } } diff --git a/src/NzbDrone.Core/Jobs/TaskManager.cs b/src/NzbDrone.Core/Jobs/TaskManager.cs index 141cd729d..e26eee045 100644 --- a/src/NzbDrone.Core/Jobs/TaskManager.cs +++ b/src/NzbDrone.Core/Jobs/TaskManager.cs @@ -47,14 +47,16 @@ namespace NzbDrone.Core.Jobs var defaultTasks = new[] { new ScheduledTask{ Interval = _configService.RssSyncInterval, TypeName = typeof(RssSyncCommand).FullName}, - new ScheduledTask{ Interval = 12*60, TypeName = typeof(RefreshSeriesCommand).FullName}, new ScheduledTask{ Interval = 1, TypeName = typeof(DownloadedEpisodesScanCommand).FullName}, - new ScheduledTask{ Interval = 60, TypeName = typeof(ApplicationUpdateCommand).FullName}, + new ScheduledTask{ Interval = 1, TypeName = typeof(TrackedCommandCleanupCommand).FullName}, + new ScheduledTask{ Interval = 1, TypeName = typeof(CheckForFailedDownloadCommand).FullName}, + new ScheduledTask{ Interval = 1*60, TypeName = typeof(ApplicationUpdateCommand).FullName}, new ScheduledTask{ Interval = 1*60, TypeName = typeof(TrimLogCommand).FullName}, new ScheduledTask{ Interval = 3*60, TypeName = typeof(UpdateSceneMappingCommand).FullName}, - new ScheduledTask{ Interval = 1, TypeName = typeof(TrackedCommandCleanupCommand).FullName}, + new ScheduledTask{ Interval = 12*60, TypeName = typeof(RefreshXemCacheCommand).FullName}, + new ScheduledTask{ Interval = 12*60, TypeName = typeof(RefreshSeriesCommand).FullName}, new ScheduledTask{ Interval = 24*60, TypeName = typeof(HousekeepingCommand).FullName}, - new ScheduledTask{ Interval = 1, TypeName = typeof(CheckForFailedDownloadCommand).FullName} + }; var currentTasks = _scheduledTaskRepository.All();