Fixed: Xem mapped series should be more reliable

This commit is contained in:
Mark McDowall
2014-01-09 17:41:08 -08:00
parent 5ada7efefc
commit 401a5c9f26
6 changed files with 19 additions and 16 deletions

View File

@@ -1,15 +1,15 @@
using System;
using System.Linq;
using System.Web.UI.WebControls;
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<SeriesUpdatedEvent>, IExecute<RefreshXemCacheCommand>
public class XemService : IHandle<SeriesUpdatedEvent>, IHandle<SeriesRefreshStartingEvent>
{
private readonly IEpisodeService _episodeService;
private readonly IXemProxy _xemProxy;
@@ -84,10 +84,13 @@ namespace NzbDrone.Core.DataAugmentation.Xem
private void RefreshCache()
{
_cache.Clear();
var ids = _xemProxy.GetXemSeriesIds();
if (ids.Any())
{
_cache.Clear();
}
foreach (var id in ids)
{
_cache.Set(id.ToString(), true, TimeSpan.FromHours(1));
@@ -110,7 +113,7 @@ namespace NzbDrone.Core.DataAugmentation.Xem
PerformUpdate(message.Series);
}
public void Execute(RefreshXemCacheCommand message)
public void Handle(SeriesRefreshStartingEvent message)
{
RefreshCache();
}