Repository navigation
sync: replace conflicting files and directories - #9696
Minghan2005 wants to merge 2 commits into
Conversation
|
CI note: the only failing job is |
11ea93a to
435ea30
Compare
Sync previously treated an identically named file and directory as unrelated entries. With delete-after this attempted the replacement before removing the conflicting destination entry, so the transfer failed. Group entries by their transformed basename while still preferring same-type matches for backends that can hold both kinds. For an actual type conflict, remove or back up the destination before continuing the sync. Preserve immutable and filtered-sync safety checks. Fixes rclone#2231
435ea30 to
5298b77
Compare
|
Rebased this branch onto current The new base includes the upstream GitHub Actions FUSE workaround from An additional ordering issue found during review is also fixed: the grouped marcher now sorts by transformed basename before entry type, so adjacent names such as Fresh local verification on the rebased branch passed:
The new workflow run is currently Could a maintainer approve this fork workflow when convenient? I will keep the PR as Draft until the new checks have actually completed. |
What does this change do?
syncnow replaces a destination directory with a source file, or a destination file with a source directory, when they have the same transformed name.The traversal groups entries by transformed basename but still prefers same-type matches. This preserves the behavior of backends such as Drive that can expose a file and directory with the same name. Only a remaining cross-type pair is treated as a replacement.
For a real type conflict, sync removes the destination before continuing. If
--backup-diris configured, files from the conflicting directory are moved into the backup tree before its directories are removed.--immutablestill refuses the replacement, and an active filtered sync refuses to purge a directory unless--delete-excludedis set.The root cause was that file and directory sort keys included their type. A same-name cross-type pair therefore arrived as separate source-only and destination-only entries, so delete-after queued the upload before removing the conflicting destination.
Tests cover both replacement directions with normal listing and
ListR, backup-directory preservation, same-type precedence, immutable mode, and filtered-sync safety.Linked issue
Fixes #2231
For new or changed backends
Not applicable; this changes core sync traversal only.
Verification
go buildRCLONE_CONFIG=/notfound go test ./fs/march ./fs/syncRCLONE_CONFIG=/notfound go test -race ./fs/march ./fs/syncPATH="$PWD:$PATH" RCLONE_CONFIG=/notfound make quicktest BRANCH=codex-fix-sync-file-dir-replacementgolangci-lint run ./fs/march/... ./fs/sync/...(0 issues)Checklist