Deduplicate identical CSS files in EPUB parsing & probe images for dimensions instead of reading the full file

Some EPUB converters emit byte-identical stylesheets per chapter (100+ entries). Now scan the ZIP central directory once to identify duplicates by CRC32 and compressed size, then skip parsing identical files. This avoids redundant ZIP lookups and SD extraction round-trips while preserving all styles since rules merge into a global set. Also add extractItemToFile helper and allowEarlyStop parameter to readItemContentsToStream.
This commit is contained in:
Justin Mitchell
2026-07-20 17:16:54 -04:00
parent 792aab6d97
commit 9d147cade9
13 changed files with 420 additions and 50 deletions
+4 -1
View File
@@ -59,7 +59,10 @@ class Epub {
bool generateThumbBmp(int height) const;
uint8_t* readItemContentsToBytes(const std::string& itemHref, size_t* size = nullptr,
bool trailingNullByte = false) const;
bool readItemContentsToStream(const std::string& itemHref, Print& out, size_t chunkSize) const;
bool readItemContentsToStream(const std::string& itemHref, Print& out, size_t chunkSize,
bool allowEarlyStop = false) const;
// Extract an item to a file on SD. On failure the partial file is removed.
bool extractItemToFile(const std::string& itemHref, const std::string& destPath) const;
bool getItemSize(const std::string& itemHref, size_t* size) const;
BookMetadataCache::SpineEntry getSpineItem(int spineIndex) const;
BookMetadataCache::TocEntry getTocItem(int tocIndex) const;