mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2026-08-28 20:08:16 +00:00
* NFC, LF RFID, iButton: write the new file before deleting the one it replaces All three apps unlinked the loaded file up front and only then wrote the replacement, so a save that failed afterwards -- full SD, card pulled, a path the filesystem rejected -- left the user with neither copy. For NFC the delete also took the shadow file with it. This is what turned #1063 from a bad results screen into destroyed data. Write first, then drop the replaced file, and only when it really is a different file. The comparison uses storage_common_equivalent_path() because /ext is case-insensitive: a Card -> card rename lands on the same file, and treating it as a rename would delete the fresh write. A .shd path is normalised to its .nfc before the comparison for the same reason (Update from Initial Card leaves one in file_path). After a successful save any shadow beside the new file is dropped, so a stale one cannot go on overriding it -- nfc_load_file() prefers a shadow whenever it exists. A failed save now restores file_path and file_name. They were rewritten on the way to failing, which was harmless while the old file had already been deleted but now leaves the app pointing at a file that was never created while the original is still on disk -- Delete would then report success having removed nothing. lfrfid_scene_save_data.c had the same delete-first pattern with no rename involved at all, so the unlink only widened the window; dropped. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * upd changelog Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>