Repository navigation
Conversation
… versa - fixes rclone#2231 If a file in the source was replaced by a directory with the same name, or a directory by a file, syncing to a destination where the two can't both exist failed. On the local backend the errors were Failed to copy: mkdir dst/name: not a directory partial file rename failed: can't move object - incompatible remotes and as there had been an error nothing was deleted from the destination, so running the sync again failed in the same way. march reported the two as unrelated: something only in the source and something only in the destination. The file was copied before what was in its way was deleted. This adds MatchTypeChanges to march to report a file and a directory with the same name as a match, unless the side with the directory has a file of that name too. The suffix march adds to names to sort directories before files now starts with a "/", which can't be in a name, so that nothing sorts between a directory and a file with the same name. This changes the order entries are processed in where one name is the start of another: "file" now comes before "file2". sync sets MatchTypeChanges when it is deleting, for destinations which aren't bucket based and can't have duplicate names, and deletes what is in the destination before copying what is in the source. This is the one case where sync deletes before copying whatever --delete-after says, as there is no other way to make the destination match. Deleting obeys --backup-dir, --max-delete and --dry-run, and what is deleted is reported as missing from the source as other deletes are. What is in the destination is left alone, and the two are synced as they were before: - with --immutable, --ignore-existing or --max-depth - with --suffix and no --backup-dir, which would only rename what is in the way - if a directory has files in it which the filters exclude and --delete-excluded isn't set - if the file in the source can't be opened - if there has already been an error, as for other deletes copy and move are unchanged. With --track-renames a file deleted to make way can no longer be the source of a rename, so is transferred again if it was moved.
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.
What does this change do?
If a file in the source is replaced by a directory of the same name, or the reverse, sync to a destination where the two can't coexist fails on every run, because nothing is deleted after an error.
march now reports the two as a match. Its sort suffix becomes "/D" and "/F" so that nothing sorts between a directory and a file of the same name (so "file" is now processed before "file2"). Sync then deletes what is in the destination before copying, as suggested in the issue.
Only when sync is deleting, and not with
--immutable,--ignore-existing,--max-depth,--suffixalone, after an error, if the source file can't be opened, or if filters would leave part of a directory behind.--backup-dir,--max-deleteand--dry-runare obeyed. copy and move are unchanged.Overlaps with #9696.
Linked issue
Fixes #2231
Checklist
test_allpasses for this backend and if submitting a new backend can provide a test account for the integration tester - see CONTRIBUTING.md.