move: add --leave-root
to control --delete-empty-src-dirs
behavior - fixes #7478
#7618
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 is the purpose of this change?
Before this change, it was not always possible to delete an empty source root directory during
rclone move
. Furthermore, the behavior was inconsistent based on whether the move was performed server-side or via the fallback to copy + delete.After this change, a
--leave-root
flag is added to control whether--delete-empty-src- dirs
deletes an empty src root. (It has no effect if--delete-empty-src-dirs=false
or if the src root isn't empty.)Note that
--leave-root
defaults tofalse
, which is arguably a breaking change, although also arguably not, since the prior behavior was already inconsistent (the root was, in fact, still deleted for server-side moves without filters.) Defaulting to false also makes it consistent with the identical option inrclone rmdirs
.This setting should be particularly helpful for users wanting to rename a directory in place.
Note that both
--delete-empty-src-dirs
and--leave-root
are effectively ignored for server-side directory move operations without filters, which always use the equivalent of--delete-empty-src-dirs=true --leave-root=false
. (This is not a change, but was not previously documented.)Was the change discussed in an issue or in the forum before?
Checklist