Skip to content

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.

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. (#113)

Joseph Milazzo280fdc07f2ee
diff --git a/API/Services/CacheService.cs b/API/Services/CacheService.cs
index 1a847fdf1..d998a4976 100644
--- a/API/Services/CacheService.cs
+++ b/API/Services/CacheService.cs
@@ -41,12 +41,19 @@ namespace API.Services
public async Task<Chapter> Ensure(int chapterId)
{
EnsureCacheDirectory();
- Chapter chapter = await _unitOfWork.VolumeRepository.GetChapterAsync(chapterId);
+ var chapter = await _unitOfWork.VolumeRepository.GetChapterAsync(chapterId);
+ var fileCount = 0;
+ var extractPath = GetCachePath(chapterId);
foreach (var file in chapter.Files)
{
- var extractPath = GetCachePath(chapterId);
- _archiveService.ExtractArchive(file.FilePath, extractPath);
+ _archiveService.ExtractArchive(file.FilePath, Path.Join(extractPath, file.Id + ""));
+ fileCount++;
+ }
+
+ if (fileCount > 1)
+ {
+ new DirectoryInfo(extractPath).Flatten();
}
return chapter;
diff --git a/build.sh b/build.sh
index 9119b76f4..a8d59b9d1 100644
--- a/build.sh
+++ b/build.sh
@@ -62,7 +62,7 @@ Package()
ProgressStart "Creating $runtime Package for $framework"
-
+ # TODO: Use no-restore? Because Build should have already done it for us
echo "Building"
cd API
echo dotnet publish -c release --self-contained --runtime $runtime -o "$lOutputFolder" --framework $framework