From 3a8a786397e6357790d0d489f34d49c7cc1e33b5 Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Fri, 17 Dec 2021 15:21:53 -0600 Subject: [PATCH] Fixed a bug in how to determine if the volume or series updates cover image. (#857) --- API/Helpers/CacheHelper.cs | 2 +- API/Services/MetadataService.cs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/API/Helpers/CacheHelper.cs b/API/Helpers/CacheHelper.cs index de663e0b5..153e73109 100644 --- a/API/Helpers/CacheHelper.cs +++ b/API/Helpers/CacheHelper.cs @@ -38,11 +38,11 @@ public class CacheHelper : ICacheHelper public bool ShouldUpdateCoverImage(string coverPath, MangaFile firstFile, DateTime chapterCreated, bool forceUpdate = false, bool isCoverLocked = false) { - if (firstFile == null) return false; var fileExists = !string.IsNullOrEmpty(coverPath) && _fileService.Exists(coverPath); if (isCoverLocked && fileExists) return false; if (forceUpdate) return true; + if (firstFile == null) return true; return (_fileService.HasFileBeenModifiedSince(coverPath, chapterCreated)) || !fileExists; } diff --git a/API/Services/MetadataService.cs b/API/Services/MetadataService.cs index 6fe469c50..4a28b7998 100644 --- a/API/Services/MetadataService.cs +++ b/API/Services/MetadataService.cs @@ -199,7 +199,9 @@ public class MetadataService : IMetadataService private bool UpdateVolumeCoverImage(Volume volume, bool forceUpdate) { // We need to check if Volume coverImage matches first chapters if forceUpdate is false - if (volume == null || !_cacheHelper.ShouldUpdateCoverImage(_directoryService.FileSystem.Path.Join(_directoryService.CoverImageDirectory, volume.CoverImage), null, volume.Created, forceUpdate)) return false; + if (volume == null || !_cacheHelper.ShouldUpdateCoverImage( + _directoryService.FileSystem.Path.Join(_directoryService.CoverImageDirectory, volume.CoverImage), + null, volume.Created, forceUpdate)) return false; volume.Chapters ??= new List(); var firstChapter = volume.Chapters.OrderBy(x => double.Parse(x.Number), _chapterSortComparerForInChapterSorting).FirstOrDefault(); @@ -218,7 +220,9 @@ public class MetadataService : IMetadataService { if (series == null) return; - if (!_cacheHelper.ShouldUpdateCoverImage(_directoryService.FileSystem.Path.Join(_directoryService.CoverImageDirectory, series.CoverImage), null, series.Created, forceUpdate, series.CoverImageLocked)) + //var firstFile = series.Volumes.FirstWithChapters().Chapters.Fir + if (!_cacheHelper.ShouldUpdateCoverImage(_directoryService.FileSystem.Path.Join(_directoryService.CoverImageDirectory, series.CoverImage), + null, series.Created, forceUpdate, series.CoverImageLocked)) return; series.Volumes ??= new List();