Fixed: Don't try to create metadata images if source files doesn't exist

Closes #6015
This commit is contained in:
Mark McDowall 2023-09-14 17:07:32 -07:00
parent a4ba3ea244
commit 9a1022386a
1 changed files with 11 additions and 3 deletions

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -443,6 +443,7 @@ namespace NzbDrone.Core.Extras.Metadata
private void DownloadImage(Series series, ImageFileResult image) private void DownloadImage(Series series, ImageFileResult image)
{ {
var fullPath = Path.Combine(series.Path, image.RelativePath); var fullPath = Path.Combine(series.Path, image.RelativePath);
var downloaded = true;
try try
{ {
@ -450,13 +451,20 @@ namespace NzbDrone.Core.Extras.Metadata
{ {
_httpClient.DownloadFile(image.Url, fullPath); _httpClient.DownloadFile(image.Url, fullPath);
} }
else else if (_diskProvider.FileExists(image.Url))
{ {
_diskProvider.CopyFile(image.Url, fullPath); _diskProvider.CopyFile(image.Url, fullPath);
} }
else
{
downloaded = false;
}
if (downloaded)
{
_mediaFileAttributeService.SetFilePermissions(fullPath); _mediaFileAttributeService.SetFilePermissions(fullPath);
} }
}
catch (HttpException ex) catch (HttpException ex)
{ {
_logger.Warn(ex, "Couldn't download image {0} for {1}. {2}", image.Url, series, ex.Message); _logger.Warn(ex, "Couldn't download image {0} for {1}. {2}", image.Url, series, ex.Message);