Kavita/API/Entities/MangaFile.cs
Robbie Davis a601942ec5
Cover generation issue on first scan flow (#517)
* Cover generation issue on first scan flow

- Fixed logic around whether a chapter cover image should be generated. New logic adds grouping priority, changes an AND to an OR and adds an additional check to see if the cover image has been lock (custom image uploaded)

* Sonar update

* Refactored out the cover image updating logic to a new call (ShouldUpdateCoverImage) and updated ONLY chapters. Added a blank slate unit test to build out conditions.

* Fixed up unit case

* Fixed some logic on when to update a cover image

* Fixed an issue where 1) we were refreshing metadata anytime we adjusted cover image on a series and 2) Cover generation wasn't properly being handled on first run.

* Cleaned up the code for when a cover image change needs to trigger a refresh metadata task

Co-authored-by: Joseph Milazzo <joseph.v.milazzo@gmail.com>
2021-08-22 11:32:38 -07:00

39 lines
1.0 KiB
C#

using System;
using System.IO;
using API.Entities.Enums;
namespace API.Entities
{
/// <summary>
/// Represents a wrapper to the underlying file. This provides information around file, like number of pages, format, etc.
/// </summary>
public class MangaFile
{
public int Id { get; set; }
/// <summary>
/// Absolute path to the archive file
/// </summary>
public string FilePath { get; set; }
/// <summary>
/// Number of pages for the given file
/// </summary>
public int Pages { get; set; }
public MangaFormat Format { get; set; }
/// <summary>
/// Last time underlying file was modified
/// </summary>
public DateTime LastModified { get; set; }
// Relationship Mapping
public Chapter Chapter { get; set; }
public int ChapterId { get; set; }
// Methods
public bool HasFileBeenModified()
{
return !File.GetLastWriteTime(FilePath).Equals(LastModified);
}
}
}