Fixed: All issues regarding Media Covers should be fixed now after apply this update. Refresh browser cache if still missing and report issues on forum.

pull/2/head
Taloth Saldono 10 years ago
parent 6c22a5ffdb
commit f5ddb36ebd

@ -13,11 +13,13 @@ namespace NzbDrone.Api.Frontend.Mappers
private static readonly Regex RegexResizedImage = new Regex(@"-\d+\.jpg($|\?)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private readonly IAppFolderInfo _appFolderInfo;
private readonly IDiskProvider _diskProvider;
public MediaCoverMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger)
: base(diskProvider, logger)
{
_appFolderInfo = appFolderInfo;
_diskProvider = diskProvider;
}
public override string Map(string resourceUrl)
@ -25,25 +27,18 @@ namespace NzbDrone.Api.Frontend.Mappers
var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar);
path = path.Trim(Path.DirectorySeparatorChar);
return Path.Combine(_appFolderInfo.GetAppDataPath(), path);
}
public override Response GetResponse(string resourceUrl)
{
var result = base.GetResponse(resourceUrl);
var resourcePath = Path.Combine(_appFolderInfo.GetAppDataPath(), path);
// Return the full sized image if someone requests a non-existing resized one.
// TODO: This code can be removed later once everyone had the update for a while.
if (result is NotFoundResponse)
if (!_diskProvider.FileExists(resourcePath) || _diskProvider.GetFileSize(resourcePath) == 0)
{
var baseResourceUrl = RegexResizedImage.Replace(resourceUrl, ".jpg$1");
if (baseResourceUrl != resourceUrl)
var baseResourcePath = RegexResizedImage.Replace(resourcePath, ".jpg$1");
if (baseResourcePath != resourcePath)
{
result = base.GetResponse(baseResourceUrl);
return baseResourcePath;
}
}
return result;
return resourcePath;
}
public override bool CanHandle(string resourceUrl)

@ -29,7 +29,7 @@ namespace NzbDrone.Api.MediaCovers
{
var filePath = Path.Combine(_appFolderInfo.GetAppDataPath(), "MediaCover", seriesId.ToString(), filename);
if (!_diskProvider.FileExists(filePath))
if (!_diskProvider.FileExists(filePath) || _diskProvider.GetFileSize(filePath) == 0)
{
// Return the full sized image if someone requests a non-existing resized one.
// TODO: This code can be removed later once everyone had the update for a while.

@ -159,7 +159,8 @@ namespace NzbDrone.Core.Test.MediaCoverTests
Subject.HandleAsync(new SeriesUpdatedEvent(_series));
ExceptionVerification.ExpectedErrors(1);
Mocker.GetMock<IImageResizer>()
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(2));
}
}
}

@ -106,15 +106,8 @@ namespace NzbDrone.Core.MediaCover
_logger.ErrorException("Couldn't download media cover for " + series, e);
}
try
{
EnsureResizedCovers(series, cover, !alreadyExists);
}
catch (Exception e)
{
_logger.ErrorException("Couldn't resize media cover for " + series + " using full size image instead.", e);
}
}
}
private void DownloadCover(Series series, MediaCover cover)
@ -158,8 +151,15 @@ namespace NzbDrone.Core.MediaCover
{
_logger.Debug("Resizing {0}-{1} for {2}", cover.CoverType, height, series);
try
{
_resizer.Resize(mainFileName, resizeFileName, height);
}
catch
{
_logger.Debug("Couldn't resize media cover {0}-{1} for {2}, using full size image instead.", cover.CoverType, height, series);
}
}
}
}

Loading…
Cancel
Save