mirror of
https://github.com/storytold/figcraft.git
synced 2026-10-25 02:47:02 -06:00
Saving and exporting wrote a truncating std::fs::write to a deterministic staging name (<path>.tmp-figcraft, <file>.figcraft.tmp) before renaming, so an unrelated file or a planted symlink at that name was clobbered or written through, and separate writers of one destination shared a staging file they could corrupt. Both paths now go through figcraft_format::write_file_atomic: a uniquely named sibling staging file is created exclusively (create_new) and written through its own handle, renamed over the destination, and removed again on any failure, so only the staging file a write created is ever touched. Tests cover pre-existing staging files and symlinks, concurrent writers, and injected rename and permission failures.