Bugfix/release cleanup (#512)
* Lots of cleanup on the warnings in the solution. Deprecated IsLastWriteLessThan and made a new method HasFileBeenModifiedSince. * Added some tests for the new extension method. * Changed filter import to use correct import * Scan Series now uses Refresh Metadata for Series, rather than library one. * Fixed an issue where cover generation wasn't properly taking forced update into consideration. Removed a case of cover generation for no reason. * Fixed series downloads not triggering backend call
This commit is contained in:
parent
2a3a08de74
commit
0d2d73e8ae
33 changed files with 116 additions and 131 deletions
|
|
@ -30,6 +30,7 @@ namespace API.Services
|
|||
private readonly IDirectoryService _directoryService;
|
||||
private static readonly RecyclableMemoryStreamManager StreamManager = new();
|
||||
private readonly NaturalSortComparer _comparer;
|
||||
private const string ComicInfoFilename = "comicinfo";
|
||||
|
||||
public ArchiveService(ILogger<ArchiveService> logger, IDirectoryService directoryService)
|
||||
{
|
||||
|
|
@ -297,7 +298,7 @@ namespace API.Services
|
|||
foreach (var entry in entries)
|
||||
{
|
||||
var filename = Path.GetFileNameWithoutExtension(entry.Key).ToLower();
|
||||
if (filename.EndsWith("comicinfo")
|
||||
if (filename.EndsWith(ComicInfoFilename)
|
||||
&& !filename.StartsWith(Parser.Parser.MacOsMetadataFileStartsWith)
|
||||
&& !Parser.Parser.HasBlacklistedFolderInPath(entry.Key)
|
||||
&& Parser.Parser.IsXml(entry.Key))
|
||||
|
|
@ -334,7 +335,7 @@ namespace API.Services
|
|||
_logger.LogDebug("Using default compression handling");
|
||||
using var archive = ZipFile.OpenRead(archivePath);
|
||||
var entry = archive.Entries.SingleOrDefault(x => !Parser.Parser.HasBlacklistedFolderInPath(x.FullName)
|
||||
&& Path.GetFileNameWithoutExtension(x.Name).ToLower() == "comicinfo"
|
||||
&& Path.GetFileNameWithoutExtension(x.Name)?.ToLower() == ComicInfoFilename
|
||||
&& !Path.GetFileNameWithoutExtension(x.Name).StartsWith(Parser.Parser.MacOsMetadataFileStartsWith)
|
||||
&& Parser.Parser.IsXml(x.FullName));
|
||||
if (entry != null)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ using API.Entities.Enums;
|
|||
using API.Extensions;
|
||||
using API.Interfaces;
|
||||
using API.Interfaces.Services;
|
||||
using Kavita.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace API.Services
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ namespace API.Services.Clients
|
|||
{
|
||||
private readonly HttpClient _client;
|
||||
private readonly ILogger<StatsApiClient> _logger;
|
||||
#pragma warning disable S1075
|
||||
private const string ApiUrl = "http://stats.kavitareader.com";
|
||||
#pragma warning restore S1075
|
||||
|
||||
public StatsApiClient(HttpClient client, ILogger<StatsApiClient> logger)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ namespace API.Services
|
|||
var fileCount = 0;
|
||||
|
||||
// Determine whether to parallelize file processing on each folder based on processor count.
|
||||
var procCount = Environment.ProcessorCount;
|
||||
//var procCount = Environment.ProcessorCount;
|
||||
|
||||
// Data structure to hold names of subfolders to be examined for files.
|
||||
var dirs = new Stack<string>();
|
||||
|
|
|
|||
|
|
@ -67,7 +67,10 @@ namespace API.Services
|
|||
public void UpdateMetadata(Chapter chapter, bool forceUpdate)
|
||||
{
|
||||
var firstFile = chapter.Files.OrderBy(x => x.Chapter).FirstOrDefault();
|
||||
if (!chapter.CoverImageLocked && ShouldFindCoverImage(chapter.CoverImage, forceUpdate) && firstFile != null && !new FileInfo(firstFile.FilePath).IsLastWriteLessThan(firstFile.LastModified))
|
||||
if (!chapter.CoverImageLocked
|
||||
&& ShouldFindCoverImage(chapter.CoverImage, forceUpdate)
|
||||
&& firstFile != null
|
||||
&& (forceUpdate || new FileInfo(firstFile.FilePath).HasFileBeenModifiedSince(firstFile.LastModified)))
|
||||
{
|
||||
chapter.Files ??= new List<MangaFile>();
|
||||
chapter.CoverImage = GetCoverImage(firstFile);
|
||||
|
|
@ -88,19 +91,7 @@ namespace API.Services
|
|||
|
||||
if (firstChapter == null) return;
|
||||
|
||||
// Skip calculating Cover Image (I/O) if the chapter already has it set
|
||||
if (!firstChapter.CoverImageLocked && ShouldFindCoverImage(firstChapter.CoverImage, forceUpdate))
|
||||
{
|
||||
// NOTE: Why do I do this? By the time this method gets executed, the chapter has already been calculated for
|
||||
// Plus how can we have a volume without at least 1 chapter?
|
||||
var firstFile = firstChapter.Files.OrderBy(x => x.Chapter).FirstOrDefault();
|
||||
if (firstFile != null && !new FileInfo(firstFile.FilePath).IsLastWriteLessThan(firstFile.LastModified))
|
||||
{
|
||||
firstChapter.CoverImage = GetCoverImage(firstFile);
|
||||
}
|
||||
}
|
||||
volume.CoverImage = firstChapter.CoverImage;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -119,7 +119,6 @@ namespace API.Services
|
|||
BackgroundJob.Enqueue(() => _cleanupService.Cleanup());
|
||||
}
|
||||
|
||||
|
||||
public void CleanupChapters(int[] chapterIds)
|
||||
{
|
||||
BackgroundJob.Enqueue(() => _cacheService.CleanupChapters(chapterIds));
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ namespace API.Services.Tasks
|
|||
totalFiles, parsedSeries.Keys.Count, sw.ElapsedMilliseconds + scanElapsedTime, series.Name);
|
||||
|
||||
CleanupDbEntities();
|
||||
BackgroundJob.Enqueue(() => _metadataService.RefreshMetadata(libraryId, forceUpdate));
|
||||
BackgroundJob.Enqueue(() => _metadataService.RefreshMetadataForSeries(libraryId, seriesId));
|
||||
BackgroundJob.Enqueue(() => _cacheService.CleanupChapters(chapterIds));
|
||||
}
|
||||
else
|
||||
|
|
@ -132,11 +132,14 @@ namespace API.Services.Tasks
|
|||
{
|
||||
ScanLibrary(lib.Id, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Scans a library for file changes. If force update passed, all entities will be rechecked for new cover images and comicInfo.xml changes.
|
||||
/// Scans a library for file changes.
|
||||
/// Will kick off a scheduled background task to refresh metadata,
|
||||
/// ie) all entities will be rechecked for new cover images and comicInfo.xml changes
|
||||
/// </summary>
|
||||
/// <param name="libraryId"></param>
|
||||
/// <param name="forceUpdate"></param>
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace API.Services.Tasks
|
|||
{
|
||||
public override HttpMessageHandler CreateMessageHandler() {
|
||||
return new HttpClientHandler {
|
||||
ServerCertificateCustomValidationCallback = (a, b, c, d) => true
|
||||
ServerCertificateCustomValidationCallback = (_, _, _, _) => true
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ namespace API.Services.Tasks
|
|||
return updates.Select(CreateDto);
|
||||
}
|
||||
|
||||
private UpdateNotificationDto? CreateDto(GithubReleaseMetadata update)
|
||||
private UpdateNotificationDto CreateDto(GithubReleaseMetadata update)
|
||||
{
|
||||
if (update == null || string.IsNullOrEmpty(update.Tag_Name)) return null;
|
||||
var version = update.Tag_Name.Replace("v", string.Empty);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue