Kavita/API/Entities/MangaFile.cs
Joe Milazzo 7616eb5b0f
UTC Dates + CDisplayEx API Enhancements (#1781)
* Introduced a new claim on the Token to get UserId as well as Username, thus allowing for many places of reduced DB calls. All users will need to reauthenticate.

Introduced UTC Dates throughout the application, they are not exposed in all DTOs, that will come later when we fully switch over. For now, Utc dates will be updated along side timezone specific dates.

Refactored get-progress/progress api to be 50% faster by reducing how much data is loaded from the query.

* Speed up the following apis:
collection/search, download/bookmarks, reader/bookmark-info, recommended/quick-reads, recommended/quick-catchup-reads, recommended/highly-rated, recommended/more-in, recommended/rediscover, want-to-read/

* Added a migration to sync all dates with their new UTC counterpart.

* Added LastReadingProgressUtc onto ChapterDto for some browsing apis, but not all.

Added LastReadingProgressUtc to reading list items.

Refactored the migration to run raw SQL which is much faster.

* Added LastReadingProgressUtc onto ChapterDto for some browsing apis, but not all.

Added LastReadingProgressUtc to reading list items.

Refactored the migration to run raw SQL which is much faster.

* Fixed the unit tests

* Fixed an issue with auto mapper which was causing progress page number to not get sent to UI

* series/volume has chapter last reading progress

* Added filesize and library name on reading list item dto for CDisplayEx.

* Some minor code cleanup

* Forgot to fill a field
2023-02-11 04:01:24 -08:00

70 lines
1.9 KiB
C#

using System;
using System.IO;
using API.Entities.Enums;
using API.Entities.Interfaces;
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 : IEntityDate
{
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>
/// How many bytes make up this file
/// </summary>
public long Bytes { get; set; }
/// <summary>
/// File extension
/// </summary>
public string Extension { get; set; }
/// <inheritdoc cref="IEntityDate.Created"/>
public DateTime Created { get; set; }
/// <summary>
/// Last time underlying file was modified
/// </summary>
/// <remarks>This gets updated anytime the file is scanned</remarks>
public DateTime LastModified { get; set; }
public DateTime CreatedUtc { get; set; }
public DateTime LastModifiedUtc { get; set; }
/// <summary>
/// Last time file analysis ran on this file
/// </summary>
public DateTime LastFileAnalysis { get; set; }
public DateTime LastFileAnalysisUtc { get; set; }
// Relationship Mapping
public Chapter Chapter { get; set; }
public int ChapterId { get; set; }
/// <summary>
/// Updates the Last Modified time of the underlying file to the LastWriteTime
/// </summary>
public void UpdateLastModified()
{
LastModified = File.GetLastWriteTime(FilePath);
LastModifiedUtc = File.GetLastWriteTimeUtc(FilePath);
}
public void UpdateLastFileAnalysis()
{
LastFileAnalysis = DateTime.Now;
LastFileAnalysisUtc = DateTime.UtcNow;
}
}