delete: preserve empty dirs in --backup-dir when deleting#967
Open
x15sr71 wants to merge 3 commits into
Open
Conversation
this demonstrates a subtle bug in PR 967
Member
|
@x15sr71 thanks for the PR! There is a subtle bug with it in the handling of files that should not go into the backup dir. I've added another test to the PR that demonstrates the bug |
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.
Description
When using
--backup--backup-dir--delete, rsync was silently removing empty directories from the destination instead of preserving them in--backup-dir. Files in those directories were backed up correctly, but the empty directories themselves were not.Root cause
delete_item()routedS_ISDIRdirectly todo_rmdir_at(), bypassing themake_backups/backup_dirlogic that only existed in the non-directory else branch.Fix
Fix attempt a
rename()intobackup-dirbeforermdir(). If the destination already exists (because child file backups already created that directory inbackup-dir, as noted by @steadytao in the issue), fall through tormdir()of the now-empty source. Ifrename()fails for any other unexpected reason (e.g. EXDEV), emit a warning and fall through tormdir().Fixes #842.
Tests added in
testsuite/backup-empty-dir_test.py:backup-dirbackup-dir/sub/from child filebackups is not destroyed when parent dir is later backed up
--backup-dir— empty dir still deleted--delete-delayvariant — backup path reached for queued deletions