diff --git a/API.Tests/Parser/MangaParserTests.cs b/API.Tests/Parser/MangaParserTests.cs index 16205fa96..917d1f467 100644 --- a/API.Tests/Parser/MangaParserTests.cs +++ b/API.Tests/Parser/MangaParserTests.cs @@ -237,6 +237,7 @@ namespace API.Tests.Parser [InlineData("Hentai Ouji to Warawanai Neko. - Vol. 06 Ch. 034.5", "34.5")] [InlineData("Kimi no Koto ga Daidaidaidaidaisuki na 100-nin no Kanojo Chapter 1-10", "1-10")] [InlineData("Deku_&_Bakugo_-_Rising_v1_c1.1.cbz", "1.1")] + [InlineData("Chapter 63 - The Promise Made for 520 Cenz.cbr", "63")] public void ParseChaptersTest(string filename, string expected) { Assert.Equal(expected, API.Parser.Parser.ParseChapter(filename)); diff --git a/API/Controllers/ImageController.cs b/API/Controllers/ImageController.cs index 02cb9ed5b..f1ddb770e 100644 --- a/API/Controllers/ImageController.cs +++ b/API/Controllers/ImageController.cs @@ -1,4 +1,6 @@ -using System.IO; +using System; +using System.IO; +using System.Net; using System.Threading.Tasks; using API.Extensions; using API.Interfaces; @@ -34,7 +36,7 @@ namespace API.Controllers var format = Path.GetExtension(path).Replace(".", ""); Response.AddCacheHeader(path); - return PhysicalFile(path, "image/" + format); + return PhysicalFile(path, "image/" + format, Path.GetFileName(path)); } /// @@ -50,7 +52,7 @@ namespace API.Controllers var format = Path.GetExtension(path).Replace(".", ""); Response.AddCacheHeader(path); - return PhysicalFile(path, "image/" + format); + return PhysicalFile(path, "image/" + format, Path.GetFileName(path)); } /// @@ -66,7 +68,7 @@ namespace API.Controllers var format = Path.GetExtension(path).Replace(".", ""); Response.AddCacheHeader(path); - return PhysicalFile(path, "image/" + format); + return PhysicalFile(path, "image/" + format, Path.GetFileName(path)); } /// @@ -82,7 +84,7 @@ namespace API.Controllers var format = Path.GetExtension(path).Replace(".", ""); Response.AddCacheHeader(path); - return PhysicalFile(path, "image/" + format); + return PhysicalFile(path, "image/" + format, Path.GetFileName(path)); } } } diff --git a/API/Controllers/ReaderController.cs b/API/Controllers/ReaderController.cs index 811d37836..ee8934b28 100644 --- a/API/Controllers/ReaderController.cs +++ b/API/Controllers/ReaderController.cs @@ -54,7 +54,7 @@ namespace API.Controllers if (string.IsNullOrEmpty(path) || !System.IO.File.Exists(path)) return BadRequest($"No such image for page {page}"); var format = Path.GetExtension(path).Replace(".", ""); - return PhysicalFile(path, "image/" + format); + return PhysicalFile(path, "image/" + format, Path.GetFileName(path)); } catch (Exception) { diff --git a/API/Data/MigrateCoverImages.cs b/API/Data/MigrateCoverImages.cs index d2b2fd280..87e65cb81 100644 --- a/API/Data/MigrateCoverImages.cs +++ b/API/Data/MigrateCoverImages.cs @@ -2,6 +2,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; +using API.Comparators; using API.Helpers; using API.Services; using Microsoft.EntityFrameworkCore; @@ -23,6 +24,8 @@ namespace API.Data /// public static class MigrateCoverImages { + private static readonly ChapterSortComparerZeroFirst ChapterSortComparerForInChapterSorting = new (); + /// /// Run first. Will extract byte[]s from DB and write them to the cover directory. /// @@ -140,6 +143,22 @@ namespace API.Data await context.SaveChangesAsync(); + Console.WriteLine("Updating Volume entities"); + var volumes = await context.Volume.Include(v => v.Chapters).ToListAsync(); + foreach (var volume in volumes) + { + var firstChapter = volume.Chapters.OrderBy(x => double.Parse(x.Number), ChapterSortComparerForInChapterSorting).FirstOrDefault(); + if (firstChapter == null) continue; + if (File.Exists(Path.Join(DirectoryService.CoverImageDirectory, + $"{ImageService.GetChapterFormat(firstChapter.Id, firstChapter.VolumeId)}.png"))) + { + volume.CoverImage = $"{ImageService.GetChapterFormat(firstChapter.Id, firstChapter.VolumeId)}.png"; + } + + } + + await context.SaveChangesAsync(); + Console.WriteLine("Updating Collection Tag entities"); var tags = await context.CollectionTag.ToListAsync(); foreach (var tag in tags) @@ -153,6 +172,7 @@ namespace API.Data } await context.SaveChangesAsync(); + Console.WriteLine("Cover Image Migration completed"); } diff --git a/API/Parser/Parser.cs b/API/Parser/Parser.cs index 4b243aeac..0c8f69744 100644 --- a/API/Parser/Parser.cs +++ b/API/Parser/Parser.cs @@ -448,7 +448,7 @@ namespace API.Parser RegexTimeout), // Hinowa ga CRUSH! 018 (2019) (Digital) (LuCaZ).cbz, Hinowa ga CRUSH! 018.5 (2019) (Digital) (LuCaZ).cbz new Regex( - @"^(?!Vol)(?.*)\s(?\d+(?:.\d+|-\d+)?)(?:\s\(\d{4}\))?(\b|_|-)", + @"^(?!Vol)(?.+?)\s(?\d+(?:.\d+|-\d+)?)(?:\s\(\d{4}\))?(\b|_|-)", RegexOptions.IgnoreCase | RegexOptions.Compiled, RegexTimeout), // Tower Of God S01 014 (CBT) (digital).cbz diff --git a/API/Services/Tasks/ScannerService.cs b/API/Services/Tasks/ScannerService.cs index 6ef453ac3..15bb715c7 100644 --- a/API/Services/Tasks/ScannerService.cs +++ b/API/Services/Tasks/ScannerService.cs @@ -128,12 +128,13 @@ namespace API.Services.Tasks [AutomaticRetry(Attempts = 0, OnAttemptsExceeded = AttemptsExceededAction.Delete)] public async Task ScanLibraries() { + _logger.LogInformation("Starting Scan of All Libraries"); var libraries = await _unitOfWork.LibraryRepository.GetLibrariesAsync(); foreach (var lib in libraries) { await ScanLibrary(lib.Id, false); } - + _logger.LogInformation("Scan of All Libraries Finished"); } diff --git a/UI/Web/src/app/admin/_modals/library-access-modal/library-access-modal.component.html b/UI/Web/src/app/admin/_modals/library-access-modal/library-access-modal.component.html index 458880b5e..de4001387 100644 --- a/UI/Web/src/app/admin/_modals/library-access-modal/library-access-modal.component.html +++ b/UI/Web/src/app/admin/_modals/library-access-modal/library-access-modal.component.html @@ -14,6 +14,9 @@ +
  • + There are no libraries setup yet. +