Repository navigation
Conversation
…ixes rclone#7478 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 to false, 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 in `rclone 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.)
8319c64 to
4be0303
Compare
ncw
left a comment
There was a problem hiding this comment.
I missed reviewing this before - sorry!
I think changing the defaults is not without risk - there is just bound to be a user or two relying on the fact that --delete-empty-src-dirs doesn't delete the root sometimes.
However I agree that this is very inconsistent and makes the rename case impossible, so arguably a bug.
The --leave-root flag should probably be on the rclone move command directly like --delete-empty-src-dirs is rather being a global though.
What do you think?
Do you want to get this into 1.68?
I think |
Yes that will be more invasive, certainly. I don't think we want a --leave-root flag on the main binary which is only useful for move though (I know there lots already but I've been trying not to add more!) We could change the function to take a moveOpts struct instead which is nice to use on the RC. And is the way the check functions work. Or if we do want to make a global then it needs a more precise name like --leave-root-on-move but I'm not keen on that. I haven't looked through the consequences of changing the move functions yet though so there may be more to it. It might be that a bigger reorg should be done with sync copy and move. Thoughts? |
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-rootflag is added to control whether--delete-empty-src- dirsdeletes an empty src root. (It has no effect if--delete-empty-src-dirs=falseor if the src root isn't empty.)Note that
--leave-rootdefaults 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-dirsand--leave-rootare 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