diff --git a/NzbDrone.Core/MediaCover/CoverAlreadyExistsSpecification.cs b/NzbDrone.Core/MediaCover/CoverAlreadyExistsSpecification.cs
index df824fe61..c634bccdb 100644
--- a/NzbDrone.Core/MediaCover/CoverAlreadyExistsSpecification.cs
+++ b/NzbDrone.Core/MediaCover/CoverAlreadyExistsSpecification.cs
@@ -1,21 +1,24 @@
-using NzbDrone.Common;
+using NLog;
+using NzbDrone.Common;
namespace NzbDrone.Core.MediaCover
{
public interface ICoverExistsSpecification
{
- bool AlreadyExists(string url, string paht);
+ bool AlreadyExists(string url, string path);
}
public class CoverAlreadyExistsSpecification : ICoverExistsSpecification
{
private readonly IDiskProvider _diskProvider;
private readonly IHttpProvider _httpProvider;
+ private readonly Logger _logger;
- public CoverAlreadyExistsSpecification(IDiskProvider diskProvider, IHttpProvider httpProvider)
+ public CoverAlreadyExistsSpecification(IDiskProvider diskProvider, IHttpProvider httpProvider, Logger logger)
{
_diskProvider = diskProvider;
_httpProvider = httpProvider;
+ _logger = logger;
}
public bool AlreadyExists(string url, string path)
@@ -27,21 +30,20 @@ namespace NzbDrone.Core.MediaCover
var headers = _httpProvider.DownloadHeader(url);
- string sizeString = null;
+ string sizeString;
- if (headers.TryGetValue(HttpProvider.ContentLenghtHeader, out sizeString))
+ if (headers.TryGetValue(headers[HttpProvider.ContentLenghtHeader], out sizeString))
{
int size;
int.TryParse(sizeString, out size);
var fileSize = _diskProvider.GetFileSize(path);
- if (fileSize != size)
- {
- return false;
- }
+ return fileSize == size;
}
- return true;
+ _logger.Warn("Couldn't read content length header {0}", headers[HttpProvider.ContentLenghtHeader]);
+
+ return false;
}
}
}
\ No newline at end of file
diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj
index 20ef8261e..54a5012ad 100644
--- a/NzbDrone.Core/NzbDrone.Core.csproj
+++ b/NzbDrone.Core/NzbDrone.Core.csproj
@@ -361,6 +361,7 @@
+
diff --git a/NzbDrone.Core/Tv/Commands/RefreshSeriesCommand.cs b/NzbDrone.Core/Tv/Commands/RefreshSeriesCommand.cs
new file mode 100644
index 000000000..f38af963c
--- /dev/null
+++ b/NzbDrone.Core/Tv/Commands/RefreshSeriesCommand.cs
@@ -0,0 +1,14 @@
+using NzbDrone.Common.Messaging;
+
+namespace NzbDrone.Core.Tv.Commands
+{
+ public class RefreshSeriesCommand : ICommand
+ {
+ public int? SeriesId { get; private set; }
+
+ public RefreshSeriesCommand(int? seriesId)
+ {
+ SeriesId = seriesId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/NzbDrone.Core/Tv/RefreshSeriesService.cs b/NzbDrone.Core/Tv/RefreshSeriesService.cs
index ef299c3f9..f20777757 100644
--- a/NzbDrone.Core/Tv/RefreshSeriesService.cs
+++ b/NzbDrone.Core/Tv/RefreshSeriesService.cs
@@ -4,6 +4,7 @@ using System.Linq;
using NLog;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.MetadataSource;
+using NzbDrone.Core.Tv.Commands;
using NzbDrone.Core.Tv.Events;
namespace NzbDrone.Core.Tv
@@ -33,15 +34,16 @@ namespace NzbDrone.Core.Tv
{
if (message.SeriesId.HasValue)
{
- RefreshSeriesInfo(message.SeriesId.Value);
+ var series = _seriesService.GetSeries(message.SeriesId.Value);
+ RefreshSeriesInfo(series);
}
else
{
- var ids = _seriesService.GetAllSeries().OrderBy(c => c.LastInfoSync).Select(c => c.Id).ToList();
+ var allSeries = _seriesService.GetAllSeries().OrderBy(c => c.LastInfoSync).ToList();
- foreach (var id in ids)
+ foreach (var series in allSeries)
{
- RefreshSeriesInfo(id);
+ RefreshSeriesInfo(series);
}
}
@@ -49,14 +51,15 @@ namespace NzbDrone.Core.Tv
public void HandleAsync(SeriesAddedEvent message)
{
- RefreshSeriesInfo(message.Series.Id);
+ RefreshSeriesInfo(message.Series);
}
- private Series RefreshSeriesInfo(int seriesId)
+ private void RefreshSeriesInfo(Series series)
{
- var series = _seriesService.GetSeries(seriesId);
var tuple = _seriesInfo.GetSeriesInfo(series.TvdbId);
+ RefreshEpisodeInfo(series, tuple.Item2);
+
var seriesInfo = tuple.Item1;
series.Title = seriesInfo.Title;
@@ -64,7 +67,7 @@ namespace NzbDrone.Core.Tv
series.Overview = seriesInfo.Overview;
series.Status = seriesInfo.Status;
series.CleanTitle = Parser.Parser.NormalizeTitle(seriesInfo.Title);
- series.LastInfoSync = DateTime.Now;
+ series.LastInfoSync = DateTime.UtcNow;
series.Runtime = seriesInfo.Runtime;
series.Images = seriesInfo.Images;
series.Network = seriesInfo.Network;
@@ -73,13 +76,10 @@ namespace NzbDrone.Core.Tv
//Todo: We need to get the UtcOffset from TVRage, since its not available from trakt
- RefreshEpisodeInfo(series, tuple.Item2);
-
_messageAggregator.PublishEvent(new SeriesUpdatedEvent(series));
- return series;
}
- private void RefreshEpisodeInfo(Series series, List remoteEpisodes)
+ private void RefreshEpisodeInfo(Series series, IEnumerable remoteEpisodes)
{
_logger.Trace("Starting episode info refresh for series: {0}", series.Title.WithDefault(series.Id));
var successCount = 0;
@@ -205,14 +205,4 @@ namespace NzbDrone.Core.Tv
_logger.Trace("Deleted episodes that no longer exist in TVDB for {0}", series.Id);
}*/
}
-
- public class RefreshSeriesCommand : ICommand
- {
- public int? SeriesId { get; private set; }
-
- public RefreshSeriesCommand(int? seriesId)
- {
- SeriesId = seriesId;
- }
- }
}
\ No newline at end of file