Implemented the LastWrite check for Summaries and Series Cover Images. Removed a TODO after validation.

This commit is contained in:
Joseph Milazzo 2021-03-24 07:41:52 -05:00
parent f85918b5bf
commit c639b8ca04
2 changed files with 12 additions and 5 deletions

View File

@ -203,7 +203,7 @@ namespace API.Services
{ {
formatExtension = "." + formatExtension; formatExtension = "." + formatExtension;
} }
// TODO: Validate if jpeg is same as jpg
try try
{ {
using var thumbnail = Image.ThumbnailBuffer(entry, ThumbnailWidth); using var thumbnail = Image.ThumbnailBuffer(entry, ThumbnailWidth);
@ -227,7 +227,7 @@ namespace API.Services
{ {
using var stream = entry.Open(); using var stream = entry.Open();
using var thumbnail = Image.ThumbnailStream(stream, ThumbnailWidth); using var thumbnail = Image.ThumbnailStream(stream, ThumbnailWidth);
return thumbnail.WriteToBuffer(formatExtension); // TODO: Validate this code works with .png files return thumbnail.WriteToBuffer(formatExtension);
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -1,9 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using API.Entities; using API.Entities;
using API.Extensions;
using API.Interfaces; using API.Interfaces;
using API.Interfaces.Services; using API.Interfaces.Services;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -51,7 +53,10 @@ namespace API.Services
// Skip calculating Cover Image (I/O) if the chapter already has it set // Skip calculating Cover Image (I/O) if the chapter already has it set
if (firstChapter == null || ShouldFindCoverImage(firstChapter.CoverImage)) if (firstChapter == null || ShouldFindCoverImage(firstChapter.CoverImage))
{ {
if (firstFile != null) volume.CoverImage = _archiveService.GetCoverImage(firstFile.FilePath, true); if (firstFile != null && !new FileInfo(firstFile.FilePath).DoesLastWriteMatch(firstFile.LastModified))
{
volume.CoverImage = _archiveService.GetCoverImage(firstFile.FilePath, true);
}
} }
else else
{ {
@ -80,9 +85,11 @@ namespace API.Services
var firstVolume = series.Volumes.FirstOrDefault(v => v.Chapters.Any() && v.Number == 1); var firstVolume = series.Volumes.FirstOrDefault(v => v.Chapters.Any() && v.Number == 1);
var firstChapter = firstVolume?.Chapters.FirstOrDefault(c => c.Files.Any()); var firstChapter = firstVolume?.Chapters.FirstOrDefault(c => c.Files.Any());
if (firstChapter != null)
var firstFile = firstChapter?.Files.FirstOrDefault();
if (firstFile != null && !new FileInfo(firstFile.FilePath).DoesLastWriteMatch(firstFile.LastModified))
{ {
series.Summary = _archiveService.GetSummaryInfo(firstChapter.Files.FirstOrDefault()?.FilePath); series.Summary = _archiveService.GetSummaryInfo(firstFile.FilePath);
} }
} }