Kavita/API/Extensions/FileInfoExtensions.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

21 lines
618 B
C#

using System;
using System.IO;
namespace API.Extensions
{
public static class FileInfoExtensions
{
/// <summary>
/// Checks if the last write time of the file is after the passed date
/// </summary>
/// <param name="fileInfo"></param>
/// <param name="comparison"></param>
/// <returns></returns>
public static bool HasFileBeenModifiedSince(this FileInfo fileInfo, DateTime comparison)
{
return DateTime.Compare(fileInfo.LastWriteTime, comparison) > 0;
//return fileInfo?.LastWriteTime > comparison;
}
}
}