mirror of
https://github.com/Radarr/Radarr
synced 2025-12-15 12:55:14 +01:00
Simplify last write time for media covers
This commit is contained in:
parent
740d3ce88c
commit
c281e68b9f
2 changed files with 13 additions and 20 deletions
|
|
@ -81,9 +81,9 @@ public Dictionary<string, FileInfo> GetCoverFileInfos()
|
|||
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 @@ public void ConvertToLocalUrls(int movieId, IEnumerable<MediaCover> covers, Dict
|
|||
|
||||
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 @@ public List<MovieResource> AllMovie(int? tmdbId, bool excludeLocalCovers = false
|
|||
{
|
||||
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 @@ public List<MovieResource> AllMovie(int? tmdbId, bool excludeLocalCovers = false
|
|||
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 @@ public List<MovieResource> AllMovie(int? tmdbId, bool excludeLocalCovers = false
|
|||
|
||||
if (!excludeLocalCovers)
|
||||
{
|
||||
var coverFileInfos = _coverMapper.GetCoverFileInfos();
|
||||
|
||||
MapCoversToLocal(moviesResources, coverFileInfos);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue