Files
gridcraft/crates
Valentin KleinandClaude Opus 5.5 4c388df949 Flush a saved workbook to disk before replacing the old one (#3178)
* Flush a saved workbook to disk before the rename

write_file renamed the temporary file over the workbook without sync_all, so a power loss right after a save could leave an empty or truncated file under the workbook's name. Sync the file before the rename and, on unix, sync the folder after it (best effort).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Tolerate file systems that cannot flush when saving

On Apple targets std's sync_all asks for F_FULLFSYNC, which network mounts refuse with ENOTTY or ENOTSUP. Treat exactly those errors (and ErrorKind::Unsupported) from the temp file's sync as 'cannot flush here' and carry on with the rename, as before the flush was added. All other errors still fail the save.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Treat raw error 25 as unsupported-flush only on Unix

On Windows 25 is ERROR_SEEK, a real failure that must not be skipped.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Save: treat Apple's ENOTSUP from F_FULLFSYNC as unsupported flush

On Apple targets ENOTSUP is 45 and std leaves it uncategorized (only
EOPNOTSUPP, 102, and ENOSYS map to ErrorKind::Unsupported), so a volume
refusing F_FULLFSYNC with ENOTSUP failed the save and deleted the
temporary file. The raw code is now matched on Apple targets only;
elsewhere 45 is a different errno and stays a failed save. The check is
split into a platform-parameterised helper so each platform's codes are
tested on any host, plus an Apple-only test on the real helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-18 08:44:04 +07:00
..
2026-11-07 17:19:20 +01:00