Fixed a bug where chapter cover images weren't being updated due to a missed not.

This commit is contained in:
Joseph Milazzo 2021-04-01 09:18:26 -05:00
parent 480c990c1b
commit 7d54923041
2 changed files with 4 additions and 4 deletions

View File

@ -10,9 +10,9 @@ namespace API.Extensions
return comparison.Equals(fileInfo.LastWriteTime); return comparison.Equals(fileInfo.LastWriteTime);
} }
public static bool IsLastWriteOlder(this FileInfo fileInfo, DateTime comparison) public static bool IsLastWriteLessThan(this FileInfo fileInfo, DateTime comparison)
{ {
return comparison > fileInfo.LastWriteTime; return fileInfo.LastWriteTime < comparison;
} }
} }
} }

View File

@ -33,7 +33,7 @@ namespace API.Services
public void UpdateMetadata(Chapter chapter, bool forceUpdate) public void UpdateMetadata(Chapter chapter, bool forceUpdate)
{ {
var firstFile = chapter.Files.OrderBy(x => x.Chapter).FirstOrDefault(); var firstFile = chapter.Files.OrderBy(x => x.Chapter).FirstOrDefault();
if (ShouldFindCoverImage(chapter.CoverImage, forceUpdate) && firstFile != null && new FileInfo(firstFile.FilePath).IsLastWriteOlder(firstFile.LastModified)) if (ShouldFindCoverImage(chapter.CoverImage, forceUpdate) && firstFile != null && !new FileInfo(firstFile.FilePath).IsLastWriteLessThan(firstFile.LastModified))
{ {
chapter.Files ??= new List<MangaFile>(); chapter.Files ??= new List<MangaFile>();
chapter.CoverImage = _archiveService.GetCoverImage(firstFile.FilePath, true); chapter.CoverImage = _archiveService.GetCoverImage(firstFile.FilePath, true);
@ -53,7 +53,7 @@ namespace API.Services
// Skip calculating Cover Image (I/O) if the chapter already has it set // Skip calculating Cover Image (I/O) if the chapter already has it set
if (firstChapter == null || ShouldFindCoverImage(firstChapter.CoverImage)) if (firstChapter == null || ShouldFindCoverImage(firstChapter.CoverImage))
{ {
if (firstFile != null && !new FileInfo(firstFile.FilePath).IsLastWriteOlder(firstFile.LastModified)) if (firstFile != null && !new FileInfo(firstFile.FilePath).IsLastWriteLessThan(firstFile.LastModified))
{ {
volume.CoverImage = _archiveService.GetCoverImage(firstFile.FilePath, true); volume.CoverImage = _archiveService.GetCoverImage(firstFile.FilePath, true);
} }