Repository navigation
v0.2.0 — Replace for exact-path atomic publication
Additive only. Move/Copy/Rename unchanged.
New API
func Replace(src, dst string) (string, error)
func (f *Flow) Replace(src, dst string) (string, error)- Moves a regular file to exactly
dst, intentionally overwriting different content without conflict suffixing. Returnsdston success. - Same-filesystem: native replace (Unix
os.Rename, WindowsMoveFileExwithMOVEFILE_REPLACE_EXISTING|WRITE_THROUGH). - Cross-filesystem: copy+sync to a temporary file in the destination directory, publish, then remove source.
- Respects
Flow.DirModeandNoCreateDirs;FindAvailableNameignored. - Source must be a regular file: symlinks/non-regular rejected with
fs.ErrInvalidwrapped inErrFailedMovingFile. - Destination symlink is replaced, not followed.
- Same-file paths (including hard links) return
ErrSameFile. - If cross-filesystem publication succeeds but source removal fails, returns
dstplus*ErrFailedRemovingOriginal— destination already committed. - No crash-durability or CAS promise; sync and close staged source before calling
Replacewhen durability matters. - On Windows, open-file sharing rules can reject replacement; error returned rather than deleting destination.
Compatibility
- Go 1.19 floor preserved,
golang.org/x/sys v0.30.0only. - Fully additive; no breaking changes.
goreleasesuggestsv0.1.1(patch) — released asv0.2.0minor per additive intent.
Verification
go vet ./...clean,go test -race ./...pass, Windows amd64go test -cok, cross-filesystem smoke on /tmp vs /dev/shm.- RoboRev job 1645 PASS (commit 4be9157); prior job 1643 flagged and fixed a symlink ordering issue in
Replace. - Windows runtime not exercised beyond cross-compile; open-file sharing caveat documented.