posixfs: move replaces an existing destination also on Windows - #230
Merged
ThomasWaldmann merged 1 commit intoSep 25, 2026
Merged
Conversation
Path.rename() replaces an existing destination on POSIX, but raises FileExistsError on Windows. Use Path.replace() so move() behaves the same everywhere and like the other backends, which all overwrite the target. This broke e.g. soft-deleting an item while a soft-deleted item of the same name already existed (borgbackup/borg#10432 CI). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PosixFS.move()usedPath.rename(), which replaces an existing destination on POSIX, but raisesFileExistsErroron Windows. Now it usesPath.replace()(likestore()already does), somove()behaves the same everywhere and like the other backends, which all overwrite the target (sftpposix_rename, s3 copy+delete, rclone/rest documented as "overwrite target").This broke e.g. soft-deleting an item while a soft-deleted item of the same name already existed. borg hits this when an archive gets back an id it had before (archive ids are hashes of the archive metadata), e.g. when tags are changed back to a previous state or on
borg rename x y; borg rename y x; borg rename x z— seen in the Windows CI of borgbackup/borg#10432.Tests:
test_move_replaces_existing:move()onto an existing name replaces it (all backends).test_move_delete_undelete: soft-delete again while a soft-deleted item of the same name exists.Not changed here: posixfs quota accounting does not subtract the size of a replaced destination on move (that is already the case on POSIX today).
🤖 Generated with Claude Code