Skip to content

Readstein 0.12.6

Latest

Choose a tag to compare

@CodeUpdaterBot CodeUpdaterBot released this 19 Nov 05:09
· 5 commits to main since this release

Backup and restore: full library, without running out of memory

This release makes Backup Library produce a complete archive of your library — every
book file as well as the metadata — and makes importing one safe on a machine that is
short on memory.

What was wrong

Backups were reading each book into memory as a single buffer, then writing the whole
thing out. With books over a gigabyte that is a gigabyte-sized allocation in the middle of
a large job, and on a 32 GB machine the app would exhaust memory and die: three runs in a
row stopped within 2.4 MB of the same byte, ~7.9 GB in, with a hard fault from
KERNELBASE.dll. The failure killed the app rather than reporting anything, and produced
a 7.9 GB archive with no end-of-central-directory record — not a zip file at all.

A second attempt at the cause — the zip worker settings — did not move that byte, and was
not the cause.

What changed

  • Books are streamed, not read whole. Both directions now move each book in bounded
    1 MB slices — into the archive when backing up, and out of it when restoring — so peak
    memory no longer tracks the size of the largest book in the library.
  • Full backups include the books. A book held in place (outside the app's own storage)
    is added under its hash directory, which is where a restore looks for it.
  • Restoring repoints the records. A backup carries each record's original path from the
    machine it was made on. A path that still resolves is left alone; one that does not is
    pointed at the extracted copy, so a restore onto a new machine gives you books you can
    actually open instead of a shelf of dead cards.
  • Alternatives are preserved. On Android, or anywhere the native file layer cannot open
    the target, both directions fall back to the previous whole-file path rather than failing.

Verified

A full backup of a 274-book library produced a 19.42 GB archive — 1,215 entries, 274 book
files, 18.76 GB of book data
— with a correct end-of-central-directory record and ZIP64
extensions, past the point where every previous run died. 97 backup tests pass, including
tests that drive the streaming paths directly through the real zip.js writer and read the
bytes back.

Thanks

To the Readest maintainers, whose reader this is built on.