refactor(epub): use archiveservice instead of epub4j to read archive (#2066)

This commit is contained in:
James Ward
2026-07-30 03:45:25 -04:00
committed by GitHub
parent dbc0ccc381
commit b67b32a227
2 changed files with 8 additions and 4 deletions
@@ -11,11 +11,11 @@ import org.booklore.model.entity.BookEntity;
import org.booklore.model.entity.BookFileEntity;
import org.booklore.model.enums.BookFileType;
import org.booklore.repository.BookRepository;
import org.booklore.service.ArchiveService;
import org.booklore.util.FileUtils;
import org.grimmory.epub4j.domain.*;
import org.grimmory.epub4j.epub.CoverDetector;
import org.grimmory.epub4j.epub.EpubReader;
import org.grimmory.epub4j.native_parsing.NativeArchive;
import org.springframework.stereotype.Service;
import java.io.*;
@@ -73,6 +73,7 @@ public class EpubReaderService {
.maximumSize(MAX_CACHE_ENTRIES)
.expireAfterAccess(Duration.ofMinutes(30))
.build();
private final ArchiveService archiveService;
private record CachedEpubMetadata(EpubBookInfo bookInfo, long lastModified,
Set<String> validPaths,
@@ -380,9 +381,7 @@ public class EpubReaderService {
}
private void streamEntryFromZip(Path epubPath, String entryName, OutputStream outputStream) throws IOException {
try (NativeArchive archive = NativeArchive.open(epubPath)) {
archive.streamEntry(entryName, outputStream);
}
archiveService.transferEntryTo(epubPath, entryName, outputStream);
}
private String guessContentType(String path) {