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.

Bugfix/series cover not setting (#527)

Joseph Milazzo6edf3b083bab
diff --git a/API.Tests/Services/MetadataServiceTests.cs b/API.Tests/Services/MetadataServiceTests.cs
index 3f550f80a..796201538 100644
--- a/API.Tests/Services/MetadataServiceTests.cs
+++ b/API.Tests/Services/MetadataServiceTests.cs
@@ -36,6 +36,13 @@ namespace API.Tests.Services
}, false, false));
}
+ [Fact]
+ public void ShouldUpdateCoverImage_OnFirstRunSeries()
+ {
+ // Represents first run
+ Assert.True(MetadataService.ShouldUpdateCoverImage(null,null, false, false));
+ }
+
[Fact]
public void ShouldUpdateCoverImage_OnSecondRun_FileModified()
{
diff --git a/API/Services/MetadataService.cs b/API/Services/MetadataService.cs
index 2db52fe3f..fe2a27172 100644
--- a/API/Services/MetadataService.cs
+++ b/API/Services/MetadataService.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.IO;
using System.Linq;
using System.Threading.Tasks;
using API.Comparators;
@@ -37,11 +36,6 @@ namespace API.Services
_imageService = imageService;
}
- private static bool IsCoverImageSet(byte[] coverImage, bool forceUpdate = false)
- {
- return forceUpdate || HasCoverImage(coverImage);
- }
-
/// <summary>
/// Determines whether an entity should regenerate cover image
/// </summary>
@@ -104,7 +98,8 @@ namespace API.Services
/// <param name="forceUpdate">Force updating cover image even if underlying file has not been modified or chapter already has a cover image</param>
public void UpdateMetadata(Volume volume, bool forceUpdate)
{
- if (volume == null || !IsCoverImageSet(volume.CoverImage, forceUpdate)) return;
+ if (volume == null || !ShouldUpdateCoverImage(volume.CoverImage, null, forceUpdate
+ , false)) return;
volume.Chapters ??= new List<Chapter>();
var firstChapter = volume.Chapters.OrderBy(x => double.Parse(x.Number), _chapterSortComparer).FirstOrDefault();