From 233def11c744c29fe8a75c09223ad73c23747466 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 2 Jun 2013 22:51:16 -0700 Subject: [PATCH] fixed media cover download issue --- .../CoverExistsSpecificationFixture.cs | 5 ++++- .../MediaCover/CoverAlreadyExistsSpecification.cs | 5 +++-- NzbDrone.Core/MediaCover/MediaCoverService.cs | 2 +- NzbDrone.Core/Tv/RefreshSeriesService.cs | 11 +++++++++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/NzbDrone.Core.Test/MediaCoverTests/CoverExistsSpecificationFixture.cs b/NzbDrone.Core.Test/MediaCoverTests/CoverExistsSpecificationFixture.cs index da0fa63f8..faffdacf0 100644 --- a/NzbDrone.Core.Test/MediaCoverTests/CoverExistsSpecificationFixture.cs +++ b/NzbDrone.Core.Test/MediaCoverTests/CoverExistsSpecificationFixture.cs @@ -5,6 +5,7 @@ using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Core.MediaCover; using NzbDrone.Core.Test.Framework; +using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MediaCoverTests { @@ -66,7 +67,9 @@ namespace NzbDrone.Core.Test.MediaCoverTests public void should_return_true_if_there_is_no_size_header_and_file_exist() { GivenExistingFileSize(100); - Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeTrue(); + Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeFalse(); + + ExceptionVerification.ExpectedWarns(1); } } } \ No newline at end of file diff --git a/NzbDrone.Core/MediaCover/CoverAlreadyExistsSpecification.cs b/NzbDrone.Core/MediaCover/CoverAlreadyExistsSpecification.cs index c634bccdb..87d8151a1 100644 --- a/NzbDrone.Core/MediaCover/CoverAlreadyExistsSpecification.cs +++ b/NzbDrone.Core/MediaCover/CoverAlreadyExistsSpecification.cs @@ -1,5 +1,6 @@ using NLog; using NzbDrone.Common; +using NzbDrone.Common.Serializer; namespace NzbDrone.Core.MediaCover { @@ -32,7 +33,7 @@ namespace NzbDrone.Core.MediaCover string sizeString; - if (headers.TryGetValue(headers[HttpProvider.ContentLenghtHeader], out sizeString)) + if (headers.TryGetValue(HttpProvider.ContentLenghtHeader, out sizeString)) { int size; int.TryParse(sizeString, out size); @@ -41,7 +42,7 @@ namespace NzbDrone.Core.MediaCover return fileSize == size; } - _logger.Warn("Couldn't read content length header {0}", headers[HttpProvider.ContentLenghtHeader]); + _logger.Warn("Couldn't find content-length header {0}", headers.ToJson()); return false; } diff --git a/NzbDrone.Core/MediaCover/MediaCoverService.cs b/NzbDrone.Core/MediaCover/MediaCoverService.cs index a212194d2..127f8a42f 100644 --- a/NzbDrone.Core/MediaCover/MediaCoverService.cs +++ b/NzbDrone.Core/MediaCover/MediaCoverService.cs @@ -53,7 +53,7 @@ namespace NzbDrone.Core.MediaCover { var fileName = GetCoverPath(series.Id, cover.CoverType); - _logger.Info("Downloading {0} for {1}", cover.CoverType, series.Title); + _logger.Info("Downloading {0} for {1} {2}", cover.CoverType, series.Title, cover.Url); _httpProvider.DownloadFile(cover.Url, fileName); } catch (Exception e) diff --git a/NzbDrone.Core/Tv/RefreshSeriesService.cs b/NzbDrone.Core/Tv/RefreshSeriesService.cs index f20777757..6b96f3ed7 100644 --- a/NzbDrone.Core/Tv/RefreshSeriesService.cs +++ b/NzbDrone.Core/Tv/RefreshSeriesService.cs @@ -6,6 +6,7 @@ using NzbDrone.Common.Messaging; using NzbDrone.Core.MetadataSource; using NzbDrone.Core.Tv.Commands; using NzbDrone.Core.Tv.Events; +using NzbDrone.Common; namespace NzbDrone.Core.Tv { @@ -43,10 +44,16 @@ namespace NzbDrone.Core.Tv foreach (var series in allSeries) { - RefreshSeriesInfo(series); + try + { + RefreshSeriesInfo(series); + } + catch (Exception e) + { + _logger.ErrorException("Couldn't refresh info for {0}".Inject(series.Title), e); + } } } - } public void HandleAsync(SeriesAddedEvent message)