fix: make atomic saves durable and preserve the file
writeAtomic renamed the temporary file over the target without syncing either: on ext4 with delayed allocation a power cut just after a save could leave a zero-length script, the exact failure autosave exists to prevent. Sync the temp file before the rename and the directory after it. While here, keep an existing file's permissions instead of forcing 0o644, and resolve symlinks first so saving through a link replaces the file it points to, not the link itself (Dropbox/dotfile setups).
This commit is contained in:
1 parent
c0a52a9040
commit
5e7ae97b57
2 files changed
+37
-5
No files matched your search
@@ -11,6 +11,10 @@ version is in the `VERSION` file.
|
||||
|
||||
- The unsaved-changes marker is now updated atomically: an edit landing while a save
|
||||
finished could make the close confirmation unreliable.
|
||||
- Saving is now durable: the file is synced to disk before it replaces the old one (a
|
||||
power cut just after a save could leave an empty script). An existing file keeps its
|
||||
permissions, and saving through a symlink replaces the file it points to instead of
|
||||
replacing the link.
|
||||
|
||||
## [1.4] - 2026-10-15
|
||||
|
||||
|
||||
Reference in new issue
Block a user