mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-14 14:22:39 +00:00
The 30 s timer ran file.recovery.save on the UI thread, and
designcraft_format::save() deflated the entire package — every linked placed
file included — into a Vec in RAM: 3.6 GB and 30-100 s of zlib inside
DesignApp::ui() per autosave on a 190-page catalogue with 4.2 GB of links.
- file.recovery.save {background: true} snapshots the dirty documents (Arc
clones; no bytes copied) and queues them on one "designcraft-recovery"
thread, skipping a document whose previous write is still in flight.
file.recovery.progress reports {written, busy, errors}; the app's timer uses
it and polls from ui_frame_end while a write is outstanding. The synchronous
command is unchanged for MCP, scripts and tests, and the web build still
writes inline (it has one thread).
- designcraft_format gains write(), streaming the package to any Write + Seek,
so a large save needs no second copy of the archive.
- A snapshot still queued or running when its document is saved, reverted or
closed is cancelled before its atomic rename; a write that lands after the
poll is discarded, so a crash cannot offer back a copy older than the saved
file. A panicking write is the job's error instead of ending the thread and
leaving the document stuck as running.
Tests: the_recovery_timer_writes_off_the_interface_thread;
recovery::a_background_save_writes_recovery_data_the_app_can_recover,
a_saved_document_is_not_written_in_the_background,
a_snapshot_whose_metadata_failed_is_still_the_documents_to_remove,
a_background_snapshot_whose_metadata_failed_is_still_the_documents_to_remove,
a_write_cancelled_midway_publishes_nothing, only_a_queued_write_is_cancelled,
a_panicking_recovery_write_is_an_error_and_the_writer_keeps_going;
format::writing_to_a_stream_makes_the_same_file_as_saving_in_memory.
Gates: cargo fmt --all --check; clippy -p designcraft-engine -p
designcraft-format -p designcraft-ui-egui --all-targets -D warnings;
cargo test -p designcraft-engine -p designcraft-format.
Part of #1923, split for review: leaving linked placed files out of snapshots
is a separate pull request on top of this one.