Skip to content

fix(update/swap): fsync before swap rename#148

Merged
indaco merged 1 commit intomainfrom
fix/update-swap-fsync
Apr 22, 2026
Merged

fix(update/swap): fsync before swap rename#148
indaco merged 1 commit intomainfrom
fix/update-swap-fsync

Conversation

@indaco
Copy link
Copy Markdown
Owner

@indaco indaco commented Apr 22, 2026

Description

Add fsync for the staged file and the parent directory around the swap rename in src/update/swap.zig. The promise of atomicity now matches the implementation: a power loss between rename and kernel flush can no longer leave <target> missing or holding partial content.

Related Issue

  • None

Notes for Reviewers

  • None

Sync the staged file after chmod and the parent directory after both
renames, so the `atomicReplace` promise survives a power loss between
the rename and the kernel flush. New `sync` seams on `fs_compat.File`
and `fs_compat.Dir` keep this plumbed through the shim — the Dir
wrapper drops to `fsync(2)` because `std.Io.Dir` has no sync vtable.

Co-authored-by: Claude-Code <noreply@anthropic.com>
Co-authored-by: ruvnet <ruvnet@users.noreply.github.com>
@indaco indaco force-pushed the fix/update-swap-fsync branch from 8b85176 to c28f3f6 Compare April 22, 2026 22:42
@indaco indaco merged commit bae1db6 into main Apr 22, 2026
3 checks passed
@indaco indaco deleted the fix/update-swap-fsync branch April 22, 2026 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant