Repository navigation
WriteFileAtomic - #333
WriteFileAtomic#333
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an atomic file-write helper for the remotefs package and aligns Windows rename behavior with POSIX overwrite semantics, supporting the rig v2 “last mile” effort.
Changes:
- Add
remotefs.WriteFileAtomic, implementing temp-file + rename atomic writes with directory creation and permission staging. - Add unit tests for
WriteFileAtomic, including an end-to-end flow viaPosixFS. - Fix
WinFS.Renameto overwrite existing destinations and improve its error formatting.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
remotefs/writefileatomic.go |
Adds WriteFileAtomic implementation using temp-then-rename semantics. |
remotefs/writefileatomic_test.go |
Adds stub-based unit tests plus an integration-style test via PosixFS. |
remotefs/winfs.go |
Updates WinFS.Rename to overwrite existing targets (-Force) and improves error context. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add remotefs.WriteFileAtomic, a package-level function that writes data to a path atomically via a temp-then-rename sequence: creates a temp file in the same directory, writes with restricted permissions (0o600), chmod's to the final perm, then renames into place. Parent directories are created as needed. Deferred Remove cleans up the temp file on any failure before the rename. Also fix WinFS.Rename: add -Force to Move-Item so it overwrites an existing destination (matching POSIX mv -f semantics), and fix the error format string to include newpath. Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add WriteFileAtomic and fix WinFS.Rename
Add remotefs.WriteFileAtomic, a package-level function that writes data
to a path atomically via a temp-then-rename sequence: creates a temp
file in the same directory, writes with restricted permissions (0o600),
chmod's to the final perm, then renames into place. Parent directories
are created as needed. Deferred Remove cleans up the temp file on any
failure before the rename.
Also fix WinFS.Rename: add -Force to Move-Item so it overwrites an
existing destination (matching POSIX mv -f semantics), and fix the
error format string to include newpath.
Part of the rig v2 last mile effort, breaking API is not a problem as rig v2 has not been released yet.