mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-16 21:15:33 -04:00
Simplify last write time for media covers
This commit is contained in:
@@ -81,9 +81,9 @@ namespace NzbDrone.Core.MediaCover
|
||||
return new Dictionary<string, FileInfo>();
|
||||
}
|
||||
|
||||
return _diskProvider
|
||||
.GetFileInfos(_coverRootFolder, true)
|
||||
.ToDictionary(x => x.FullName, PathEqualityComparer.Instance);
|
||||
return _diskProvider
|
||||
.GetFileInfos(_coverRootFolder, true)
|
||||
.ToDictionary(x => x.FullName, PathEqualityComparer.Instance);
|
||||
}
|
||||
|
||||
public void ConvertToLocalUrls(int movieId, IEnumerable<MediaCover> covers, Dictionary<string, FileInfo> fileInfos = null)
|
||||
@@ -109,22 +109,20 @@ namespace NzbDrone.Core.MediaCover
|
||||
|
||||
mediaCover.Url = _configFileProvider.UrlBase + @"/MediaCover/" + movieId + "/" + mediaCover.CoverType.ToString().ToLower() + GetExtension(mediaCover.CoverType);
|
||||
|
||||
FileInfo file;
|
||||
var fileExists = false;
|
||||
if (fileInfos != null)
|
||||
DateTime? lastWrite = null;
|
||||
|
||||
if (fileInfos != null && fileInfos.TryGetValue(filePath, out var file))
|
||||
{
|
||||
fileExists = fileInfos.TryGetValue(filePath, out file);
|
||||
lastWrite = file.LastWriteTimeUtc;
|
||||
}
|
||||
else
|
||||
else if (_diskProvider.FileExists(filePath))
|
||||
{
|
||||
file = _diskProvider.GetFileInfo(filePath);
|
||||
fileExists = file.Exists;
|
||||
lastWrite = _diskProvider.FileGetLastWrite(filePath);
|
||||
}
|
||||
|
||||
if (fileExists)
|
||||
if (lastWrite.HasValue)
|
||||
{
|
||||
var lastWrite = file.LastWriteTimeUtc;
|
||||
mediaCover.Url += "?lastWrite=" + lastWrite.Ticks;
|
||||
mediaCover.Url += "?lastWrite=" + lastWrite.Value.Ticks;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,8 +118,6 @@ namespace Radarr.Api.V3.Movies
|
||||
{
|
||||
var moviesResources = new List<MovieResource>();
|
||||
|
||||
Dictionary<string, FileInfo> coverFileInfos = null;
|
||||
|
||||
var translationLanguage = languageId is > 0
|
||||
? Language.All.Single(l => l.Id == languageId.Value)
|
||||
: (Language)_configService.MovieInfoLanguage;
|
||||
@@ -146,11 +144,6 @@ namespace Radarr.Api.V3.Movies
|
||||
var tdict = translations.ToDictionaryIgnoreDuplicates(x => x.MovieMetadataId);
|
||||
var sdict = movieStats.ToDictionary(x => x.MovieId);
|
||||
|
||||
if (!excludeLocalCovers)
|
||||
{
|
||||
coverFileInfos = _coverMapper.GetCoverFileInfos();
|
||||
}
|
||||
|
||||
var movies = movieTask.GetAwaiter().GetResult();
|
||||
|
||||
moviesResources = new List<MovieResource>(movies.Count);
|
||||
@@ -163,6 +156,8 @@ namespace Radarr.Api.V3.Movies
|
||||
|
||||
if (!excludeLocalCovers)
|
||||
{
|
||||
var coverFileInfos = _coverMapper.GetCoverFileInfos();
|
||||
|
||||
MapCoversToLocal(moviesResources, coverFileInfos);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user