feat(anki): robust zstd decode via a retry-doubling buffer #765

Merged
raisondetredev merged 1 commit from refs/pull/765/head into main 2026-07-14 12:35:38 +02:00
raisondetredev commented 2026-07-14 12:35:24 +02:00 (Migrated from codeberg.org)

Closes the known limitation from #764: a modern collection compressing
better than ~8x overflowed zstd_dart's fixed srcSize*8 output buffer and
fell back to re-export guidance. Anki's frames carry no stored
content-size, so the output can't be pre-sized; instead we reuse
zstd_dart's low-level FFI bindings and retry ZSTD_decompress with a
doubling buffer (up to a 1 GiB ceiling) until the frame fits — so any
compression ratio decodes.

  • anki_zstd_io.dart: retry-doubling decode. A corrupt frame fails fast
    (ZSTD_getFrameContentSize error sentinel); only the "destination buffer
    too small" case grows the buffer.
  • ffi promoted from transitive to a direct dependency (FFI buffers).
  • anki_zstd_test.dart: round-trip, a >8x no-content-size frame that forces
    the grow loop (27 bytes -> 200 000 zero bytes), corrupt, and empty.
Closes the known limitation from #764: a modern collection compressing better than ~8x overflowed zstd_dart's fixed srcSize*8 output buffer and fell back to re-export guidance. Anki's frames carry no stored content-size, so the output can't be pre-sized; instead we reuse zstd_dart's low-level FFI bindings and retry ZSTD_decompress with a doubling buffer (up to a 1 GiB ceiling) until the frame fits — so any compression ratio decodes. - anki_zstd_io.dart: retry-doubling decode. A corrupt frame fails fast (ZSTD_getFrameContentSize error sentinel); only the "destination buffer too small" case grows the buffer. - ffi promoted from transitive to a direct dependency (FFI buffers). - anki_zstd_test.dart: round-trip, a >8x no-content-size frame that forces the grow loop (27 bytes -> 200 000 zero bytes), corrupt, and empty.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
project-halkyon/halkyon-learn!765
No description provided.