From 55d47eb1b9d5cdb63392f4d4e16feaead0297e22 Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Sat, 27 Mar 2021 15:20:55 -0500 Subject: [PATCH] Bugfix/multiple file extract (#116) * Fixed a bug where if a chapter had multiple archive files, they wouldn't all be extracted due to short circuit in ExtractArchive. Now I add the file id then flatten afterwards. * Fixed a bug where due to how we were extracting for multiple files, the single file extractions failed. * Bumped release for 3.5 release --- API/Services/CacheService.cs | 13 +++++++++---- API/Startup.cs | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/API/Services/CacheService.cs b/API/Services/CacheService.cs index d998a4976..2a2b8e482 100644 --- a/API/Services/CacheService.cs +++ b/API/Services/CacheService.cs @@ -42,13 +42,18 @@ namespace API.Services { EnsureCacheDirectory(); var chapter = await _unitOfWork.VolumeRepository.GetChapterAsync(chapterId); - var fileCount = 0; + var files = chapter.Files.ToList(); + var fileCount = files.Count; var extractPath = GetCachePath(chapterId); + var extraPath = ""; - foreach (var file in chapter.Files) + foreach (var file in files) { - _archiveService.ExtractArchive(file.FilePath, Path.Join(extractPath, file.Id + "")); - fileCount++; + if (fileCount > 1) + { + extraPath = file.Id + ""; + } + _archiveService.ExtractArchive(file.FilePath, Path.Join(extractPath, extraPath)); } if (fileCount > 1) diff --git a/API/Startup.cs b/API/Startup.cs index 65cde44f0..081249137 100644 --- a/API/Startup.cs +++ b/API/Startup.cs @@ -136,7 +136,7 @@ namespace API applicationLifetime.ApplicationStopping.Register(OnShutdown); applicationLifetime.ApplicationStarted.Register(() => { - Console.WriteLine("Kavita - v0.3.1"); + Console.WriteLine("Kavita - v0.3.5"); }); }