mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2026-01-06 03:42:34 +01:00
* fix(archive): unify CBZ generation to produce deterministic archives Previously, CBZ files generated on-the-fly (`FolderProvider`) had a different hash than those created directly (`ArchiveProvider`), even with identical content. This inconsistency was caused by using two different ZIP libraries (`java.util.zip` vs. `org.apache.commons.compress`) and not normalizing file metadata. This inconsistent hashing breaks binary-based synchronization with external services like KOReader Sync Server, as the same chapter could be identified as a different file on each generation. This change ensures CBZ generation is fully deterministic by: - Unifying both providers to use `org.apache.commons.compress`. - Setting a fixed epoch timestamp (`time = 0L`) for all ZIP entries. - Explicitly setting the compression method and level to `DEFLATED` with default compression. This guarantees that a CBZ file for a given chapter will always have the same hash, regardless of how it's generated, resolving synchronization issues. * feat(kosync): lazily generate and cache CBZ hashes for sync Previously, KOReader progress sync in binary mode was limited to chapters explicitly downloaded as CBZ files. Chapters stored as folders lacked a hash, preventing them from being synced. With the recent move to deterministic CBZ generation, it's now possible to create a consistent hash for any downloaded chapter on-the-fly. This commit enhances the `getOrGenerateChapterHash` function to act as a central point for hash management. If a hash is requested for a downloaded chapter that doesn't have one cached in the database: 1. It generates the CBZ archive in-memory from the downloaded folder or existing CBZ using `ChapterDownloadHelper.getAsArchiveStream()`. 2. It calculates the deterministic hash of the generated archive content. 3. It saves this hash to the `koreader_hash` column in the `Chapter` table for future use. The cached hash is cleared when the chapter download is deleted, ensuring hashes are only tracked for available content. This change transparently extends Koreader Sync compatibility to all downloaded chapters, regardless of their storage format, without requiring users to pre-convert their library to CBZ. * fix: rename getAsArchiveStream to getArchiveStreamWithSize