Moved try/catch for failed refresh episode info to job.

This commit is contained in:
Mark McDowall 2012-01-04 11:24:17 -08:00
parent e958a019ed
commit e4985cbd66
2 changed files with 19 additions and 14 deletions

View File

@ -1,5 +1,7 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using NLog;
using Ninject; using Ninject;
using NzbDrone.Core.Helpers; using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Model.Notification;
@ -13,6 +15,7 @@ namespace NzbDrone.Core.Jobs
private readonly SeriesProvider _seriesProvider; private readonly SeriesProvider _seriesProvider;
private readonly EpisodeProvider _episodeProvider; private readonly EpisodeProvider _episodeProvider;
private readonly ReferenceDataProvider _referenceDataProvider; private readonly ReferenceDataProvider _referenceDataProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject] [Inject]
public UpdateInfoJob(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, public UpdateInfoJob(SeriesProvider seriesProvider, EpisodeProvider episodeProvider,
@ -55,10 +58,19 @@ namespace NzbDrone.Core.Jobs
foreach (var series in seriesToUpdate) foreach (var series in seriesToUpdate)
{ {
notification.CurrentMessage = "Updating " + series.Title; try
_seriesProvider.UpdateSeriesInfo(series.SeriesId); {
_episodeProvider.RefreshEpisodeInfo(series); notification.CurrentMessage = "Updating " + series.Title;
notification.CurrentMessage = "Update completed for " + series.Title; _seriesProvider.UpdateSeriesInfo(series.SeriesId);
_episodeProvider.RefreshEpisodeInfo(series);
notification.CurrentMessage = "Update completed for " + series.Title;
}
catch(Exception ex)
{
Logger.ErrorException("Failed to update episode info for series: " + series.Title, ex);
}
} }
} }
} }

View File

@ -321,15 +321,8 @@ namespace NzbDrone.Core.Providers
} }
} }
try _database.InsertMany(newList);
{ _database.UpdateMany(updateList);
_database.InsertMany(newList);
_database.UpdateMany(updateList);
}
catch(Exception ex)
{
Logger.WarnException("Failed to update episode info for series: " + series.Title, ex);
}
Logger.Info("Finished episode refresh for series: {0}. Successful: {1} - Failed: {2} ", Logger.Info("Finished episode refresh for series: {0}. Successful: {1} - Failed: {2} ",
tvDbSeriesInfo.SeriesName, successCount, failCount); tvDbSeriesInfo.SeriesName, successCount, failCount);