Fixed relative path issue in Metadata handling.
This commit is contained in:
parent
f1c007c5fe
commit
b3eee50892
|
@ -264,9 +264,11 @@ namespace NzbDrone.Core.Metadata
|
|||
|
||||
foreach (var image in consumer.SeriesImages(series))
|
||||
{
|
||||
if (_diskProvider.FileExists(image.RelativePath))
|
||||
var fullPath = Path.Combine(series.Path, image.RelativePath);
|
||||
|
||||
if (_diskProvider.FileExists(fullPath))
|
||||
{
|
||||
_logger.Debug("Series image already exists: {0}", image.RelativePath);
|
||||
_logger.Debug("Series image already exists: {0}", fullPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -280,8 +282,7 @@ namespace NzbDrone.Core.Metadata
|
|||
RelativePath = image.RelativePath
|
||||
};
|
||||
|
||||
_diskProvider.CopyFile(image.Url, Path.Combine(series.Path, image.RelativePath));
|
||||
_mediaFileAttributeService.SetFilePermissions(image.RelativePath);
|
||||
DownloadImage(series, image);
|
||||
|
||||
result.Add(metadata);
|
||||
}
|
||||
|
@ -293,17 +294,15 @@ namespace NzbDrone.Core.Metadata
|
|||
{
|
||||
var result = new List<MetadataFile>();
|
||||
|
||||
foreach (var seasonItem in series.Seasons)
|
||||
foreach (var season in series.Seasons)
|
||||
{
|
||||
var season = seasonItem;
|
||||
foreach (var image in consumer.SeasonImages(series, season))
|
||||
{
|
||||
var fullPath = Path.Combine(series.Path, image.RelativePath);
|
||||
|
||||
foreach (var imageItem in consumer.SeasonImages(series, season))
|
||||
if (_diskProvider.FileExists(fullPath))
|
||||
{
|
||||
var image = imageItem;
|
||||
|
||||
if (_diskProvider.FileExists(image.RelativePath))
|
||||
{
|
||||
_logger.Debug("Season image already exists: {0}", image.RelativePath);
|
||||
_logger.Debug("Season image already exists: {0}", fullPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -319,7 +318,7 @@ namespace NzbDrone.Core.Metadata
|
|||
RelativePath = image.RelativePath
|
||||
};
|
||||
|
||||
DownloadImage(series, image.Url, image.RelativePath);
|
||||
DownloadImage(series, image);
|
||||
|
||||
result.Add(metadata);
|
||||
}
|
||||
|
@ -338,7 +337,7 @@ namespace NzbDrone.Core.Metadata
|
|||
|
||||
if (_diskProvider.FileExists(fullPath))
|
||||
{
|
||||
_logger.Debug("Episode image already exists: {0}", image.RelativePath);
|
||||
_logger.Debug("Episode image already exists: {0}", fullPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -367,7 +366,7 @@ namespace NzbDrone.Core.Metadata
|
|||
RelativePath = image.RelativePath
|
||||
};
|
||||
|
||||
DownloadImage(series, image.Url, fullPath);
|
||||
DownloadImage(series, image);
|
||||
|
||||
result.Add(metadata);
|
||||
}
|
||||
|
@ -375,20 +374,29 @@ namespace NzbDrone.Core.Metadata
|
|||
return result;
|
||||
}
|
||||
|
||||
private void DownloadImage(Series series, string url, string relativePath)
|
||||
private void DownloadImage(Series series, ImageFileResult image)
|
||||
{
|
||||
var fullPath = Path.Combine(series.Path, image.RelativePath);
|
||||
|
||||
try
|
||||
{
|
||||
_httpClient.DownloadFile(url, Path.Combine(series.Path, relativePath));
|
||||
_mediaFileAttributeService.SetFilePermissions(relativePath);
|
||||
}
|
||||
catch (WebException e)
|
||||
if (image.Url.StartsWith("http"))
|
||||
{
|
||||
_logger.Warn("Couldn't download image {0} for {1}. {2}", url, series, e.Message);
|
||||
_httpClient.DownloadFile(image.Url, fullPath);
|
||||
}
|
||||
catch (Exception e)
|
||||
else
|
||||
{
|
||||
_logger.Error(e, "Couldn't download image " + url + " for " + series);
|
||||
_diskProvider.CopyFile(image.Url, fullPath);
|
||||
}
|
||||
_mediaFileAttributeService.SetFilePermissions(fullPath);
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
_logger.Warn(ex, "Couldn't download image {0} for {1}. {2}", image.Url, series, ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "Couldn't download image {0} for {1}. {2}", image.Url, series, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue