Repository navigation
Conversation
A page's ink.svg that could not be read, or that held lines with no pen readings, loaded as an empty or partial drawing, and the next save wrote that drawing over the file, losing everything else in it without a word (AlienTechSoftware#157). The pad now marks such a file incomplete and, before it first writes over it or takes it away, copies it as it was to ink.svg.bak (or the next free name). The window says where the original was kept. Fixes AlienTechSoftware#157 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Audit finding: the backup protection is not connected to the browser's virtual filesystem. The inkpad browser patch imports the virtual std shim, but these new
Using a file written through the actual virtual fs, a probe reports Also, Please use virtual metadata for existence/type checks and add exclusive creation to the browser fs boundary, with a test that edits unreadable/flat ink in the virtual notebook and verifies the exact original bytes survive. Holding this PR out of the merge batch until the browser path is covered. |
What and why
Fixes #157.
inkpad::Pad::of_pageturned a read or parse failure ofink.svginto an empty layer (.ok()…unwrap_or_else(empty)). It counted paths without NoteCraft pen readings inflat, but dropped them from the drawing. The nextPad::savewrote only the drawing over the same file, or deleted it when the drawing was empty. The issue's red path, or an unreadable file, was silently destroyed as soon as the user drew one stroke.This takes the issue's "recovery/backup path" option, so nothing in the file is ever lost:
Padgainsincomplete, set whenink.svgexists but couldn't be read or parsed, or when it holdsflat > 0uneditable paths.Pad::savecopies it byte-for-byte toink.svg.bak, or the first freeink-N.svg.bak, opened withcreate_newso nothing is overwritten. It records the path inkept_original, and later saves don't make more copies. The.bakextension keeps the copy out of ink detection and picture handling.Files NoteCraft wrote itself and read back whole are saved exactly as before, with no copy.
Preserving uneditable paths inside the edited drawing would be a larger change to the ink model. The backup makes sure that, until then, nothing is lost.
How it was checked
inkpad::tests::ink_that_cannot_all_be_read_is_kept_before_it_is_written_over:incomplete, saving new ink keeps the original byte-for-byte atink.svg.bak, and a second save makes no second copycargo test -p notecraft-ui-egui: all pass (303 unit, 200 UI)cargo xtask i18n-audit,cargo xtask text: passcargo fmt --all -- --check,cargo clippy -p notecraft-ui-egui --all-targets -- -D warnings: clean🤖 Generated with Claude Code