Repository navigation
fix(ui-egui): Save picture never writes over an existing file (#158) - #177
Conversation
Draw > Save picture always wrote `ink-picture.svg`, replacing whatever was there: a picture saved earlier and kept, or another file of the owner's under that name (AlienTechSoftware#158). It now writes the first free name of `ink-picture.svg`, `ink-picture-2.svg`, ... and opens it with `create_new`, so a taken name is never written over. The window already says where the picture went. Fixes AlienTechSoftware#158 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Audit finding: this changes Save picture from the browser's virtual Checked On wasm the inherited native OpenOptions cannot write the virtual notebook, so the new export path will fail. Please provide a virtual exclusive-create operation (with a matching browser test) or isolate the native implementation behind a platform boundary. Holding this PR out of the merge batch for this browser regression. |
What and why
Fixes #158.
inkpad::Pad::save_plain(Draw › Save picture) always wroteink-picture.svgbeside the page withfs::write, silently replacing any file already there: an earlier export kept on purpose, or an unrelated file with that name.It now writes to the first free name of
ink-picture.svg,ink-picture-2.svg,ink-picture-3.svg, … (up to 10,000, then it reports an error). Each candidate is opened withOpenOptions::create_new, so a taken name is refused atomically and never written over.app.ink_export_plainalready reports the returned path ("Saved the drawing as a picture: …"), so the user sees which file was made.This picks the issue's "generate a unique snapshot name" option. A Save As dialog could be added later, but would be a larger UI change.
How it was checked
inkpad::tests::ink_is_written_beside_the_page_and_comes_back_as_strokes, extended: with an owner's file already atink-picture.svg, Save picture writesink-picture-2.svgand leaves the owner's bytes unchanged. A third save writesink-picture-3.svg.ink-picture.svg.cargo test -p notecraft-ui-egui: all pass (302 unit, 200 UI)cargo fmt --all -- --check,cargo clippy -p notecraft-ui-egui --all-targets -- -D warnings: clean🤖 Generated with Claude Code