Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--delete-empty-src-dirs improvement on rclone move (--leave-root=false) #7478

Open
cberni opened this issue Dec 1, 2023 · 0 comments · May be fixed by #7618
Open

--delete-empty-src-dirs improvement on rclone move (--leave-root=false) #7478

cberni opened this issue Dec 1, 2023 · 0 comments · May be fixed by #7618

Comments

@cberni
Copy link

cberni commented Dec 1, 2023

The associated forum post URL from https://forum.rclone.org

https://forum.rclone.org/t/rclone-rcd-move-folder-doesnt-delete-empty-source-folder/15080

What is your current rclone version (output from rclone version)?

rclone v1.62.2

  • os/version: ubuntu 22.04 (64 bit)
  • os/kernel: 5.15.0-83-generic (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.20.2
  • go/linking: static
  • go/tags: none

What problem are you are trying to solve?

delete the root directory after completed move if the folder is empty. There will be some cases that can be left files when using filters.
rclone move /local/test/dir remote:bucket/test/dir
the folder /local/test/dir is leaved empty.

How do you think rclone should be changed to solve that?

just remove the root directory if the folder is empty. --leave-root=false flag as @ncw noted.

rclone move /local/test/dir remote:bucket/test/dir --no-traverse --fast-list --delete-empty-src-dirs --leave-root=false -v -P
Error: unknown flag: --leave-root
Usage:
  rclone move source:path dest:path [flags]

Flags:
      --create-empty-src-dirs   Create empty source dirs on destination after move
      --delete-empty-src-dirs   Delete empty source dirs after move
  -h, --help                    help for move

Use "rclone [command] --help" for more information about a command.
Use "rclone help flags" for to see the global flags.
Use "rclone help backends" for a list of supported services.

2023/12/01 17:20:06 Fatal error: unknown flag: --leave-root

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.
nielash added a commit to nielash/rclone that referenced this issue Feb 6, 2024
…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.)
nielash added a commit to nielash/rclone that referenced this issue Feb 6, 2024
…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.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants