Skip to content

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.

Don't go to archive file if it hasn't updated since last scan (#135)

Joseph Milazzo667d1d2a4d64
diff --git a/API/Extensions/FileInfoExtensions.cs b/API/Extensions/FileInfoExtensions.cs
index eda352fc8..d96b06de6 100644
--- a/API/Extensions/FileInfoExtensions.cs
+++ b/API/Extensions/FileInfoExtensions.cs
@@ -9,5 +9,10 @@ namespace API.Extensions
{
return comparison.Equals(fileInfo.LastWriteTime);
}
+
+ public static bool IsLastWriteOlder(this FileInfo fileInfo, DateTime comparison)
+ {
+ return comparison > fileInfo.LastWriteTime;
+ }
}
}
\ No newline at end of file
diff --git a/API/Services/MetadataService.cs b/API/Services/MetadataService.cs
index 12d39cbf3..405e4c7e1 100644
--- a/API/Services/MetadataService.cs
+++ b/API/Services/MetadataService.cs
@@ -32,19 +32,17 @@ namespace API.Services
public void UpdateMetadata(Chapter chapter, bool forceUpdate)
{
- // TODO: Figure a way to skip UpdateMetadata: && new FileInfo(chapter.Files.FirstOrDefault()?.FilePath).LastWriteTime <
- if (chapter != null && ShouldFindCoverImage(chapter.CoverImage, forceUpdate))
+ var firstFile = chapter.Files.OrderBy(x => x.Chapter).FirstOrDefault();
+ if (ShouldFindCoverImage(chapter.CoverImage, forceUpdate) && firstFile != null && new FileInfo(firstFile.FilePath).IsLastWriteOlder(firstFile.LastModified))
{
chapter.Files ??= new List<MangaFile>();
- var firstFile = chapter.Files.OrderBy(x => x.Chapter).FirstOrDefault();
- if (firstFile != null) chapter.CoverImage = _archiveService.GetCoverImage(firstFile.FilePath, true);
+ chapter.CoverImage = _archiveService.GetCoverImage(firstFile.FilePath, true);
}
}
public void UpdateMetadata(Volume volume, bool forceUpdate)
{
- // TODO: Figure a way to skip UpdateMetadata:
if (volume != null && ShouldFindCoverImage(volume.CoverImage, forceUpdate))
{
// TODO: Create a custom sorter for Chapters so it's consistent across the application
@@ -55,7 +53,7 @@ namespace API.Services
// Skip calculating Cover Image (I/O) if the chapter already has it set
if (firstChapter == null || ShouldFindCoverImage(firstChapter.CoverImage))
{
- if (firstFile != null && !new FileInfo(firstFile.FilePath).DoesLastWriteMatch(firstFile.LastModified))
+ if (firstFile != null && !new FileInfo(firstFile.FilePath).IsLastWriteOlder(firstFile.LastModified))
{
volume.CoverImage = _archiveService.GetCoverImage(firstFile.FilePath, true);
}