Skip to content

posixfs: move replaces an existing destination also on Windows - #230

Merged
ThomasWaldmann merged 1 commit into
borgbackup:mainfrom
ThomasWaldmann:posixfs-move-replace
Sep 25, 2026
Merged

ThomasWaldmann merged 1 commit into
borgbackup:mainfrom
ThomasWaldmann:posixfs-move-replace

Conversation

@ThomasWaldmann

Copy link
Copy Markdown
Member

PosixFS.move() used Path.rename(), which replaces an existing destination on POSIX, but raises FileExistsError on Windows. Now it uses Path.replace() (like store() already does), so move() behaves the same everywhere and like the other backends, which all overwrite the target (sftp posix_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

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>
@ThomasWaldmann
ThomasWaldmann merged commit 621d9fa into borgbackup:main Sep 25, 2026
9 checks passed
@ThomasWaldmann
ThomasWaldmann deleted the posixfs-move-replace branch September 25, 2026 21:20
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