Skip to content

sync fails to remove directories on the destination that do not exist on the source #6437

Closed

Description

@eharris

What is the problem you are having with rclone?

I have noticed that under some circumstances (in my case, using a crypted remote) rclone sync fails to remove directories that should be removed since they do not exist on the source. In my particular circumstance, it seems like the problem is that rclone sync uses something like the rmdir command, which (somewhat silently) fails if the directory has any contents left, even broken contents that rclone is ignoring.

I think this could be fixed by making the sync use purge functionality instead of rmdir to remove directories that don't exist on the source.

Here is the output from the rclone sync command, which claims that it has deleted 23 directories.

> rclone sync --progress --bwlimit 1M --links --track-renames --track-renames-strategy size,leaf,modtime --transfers 10 --max-backlog 20 --tpslimit 40 /raid/audio odc:audio
Transferred:              0 B / 0 B, -, 0 B/s, ETA -
Checks:            296345 / 296345, 100%
Deleted:                0 (files), 23 (dirs)
Elapsed time:     13m50.5s

However, a subsequent run of the sync without any changes being made still shows it trying to remove the 23 directories it claimed it had removed on the last run. Note that no warnings or errors were reported at all (which is a separate problem).

So I ran again with -v to see what was going on with the directories it thought it was removing and got messages like this:

2022-09-12 16:44:10 INFO  : work/new/waiting/Johann_Sebastian_Bach_Canadian_Brass_-_Art_Of_The_Fugue: Removing directory
2022-09-12 16:44:10 INFO  : work/new/waiting/Johann Sebastian Bach; Canadian Brass - Art of the Fugue: Removing directory

Note that again, even with -v, no warnings or errors are reported with the supposedly removed directories.

So I tried manually listing (with lsl) one of the problem directories:

> rclone lsl odc:audio/work/new/waiting/Johann_Sebastian_Bach_Canadian_Brass_-_Art_Of_The_Fugue
>

Apparently no contents. So I tried rmdir on that directory:

> rclone rmdir odc:audio/work/new/waiting/Johann_Sebastian_Bach_Canadian_Brass_-_Art_Of_The_Fugue2022/09/12 16:48:06 ERROR : Attempt 1/3 failed with 1 errors and: folder not empty
2022/09/12 16:48:06 ERROR : Attempt 2/3 failed with 1 errors and: folder not empty
2022/09/12 16:48:06 ERROR : Attempt 3/3 failed with 1 errors and: folder not empty
2022/09/12 16:48:06 Failed to rmdir: folder not empty

So I tried listing the directory again with lsl -v and still got no info. Tried again with lsl -vv and finally got some useful info:

rclone lsl -vv odc:audio/work/new/waiting/Johann_Sebastian_Bach_Canadian_Brass_-_Art_Of_The_Fugue
2022/09/12 16:50:19 DEBUG : rclone: Version "v1.59.2-beta.6379.603efbfe7" starting with parameters ["rclone" "lsl" "-vv" "odc:audio/work/new/waiting/Johann_Sebastian_Bach_Canadian_Brass_-_Art_Of_The_Fugue"]
2022/09/12 16:50:19 DEBUG : Creating backend with remote "odc:audio/work/new/waiting/Johann_Sebastian_Bach_Canadian_Brass_-_Art_Of_The_Fugue"
2022/09/12 16:50:19 DEBUG : Using config file from "<redacted>"
2022/09/12 16:50:19 DEBUG : Creating backend with remote "od:<redacted>"
2022/09/12 16:50:20 DEBUG : Starting OpenDrive session with ID: <redacted>
2022/09/12 16:50:22 DEBUG : 7lnt06c8j2d8pvtcjv5nav7r5leij3atc8nn371onikjps3jbqk8gscemr6fpeibni2pame6u9hmp32kq50llb81i7vf2sbgu3jifh9k9q542dgnp9b9hira8q0l23luc57me0lm0dreqce9tdmems3es9a7v9nnk82ljvbmmqvf4khe3s4r69ethvqjka3pvccub6bi3hftu623tnjonrtuq12i7atloj8g0oc4538kto2jtmgvjpbtj1bsb2d: Skipping undecryptable file name: not a multiple of blocksize
2022/09/12 16:50:22 DEBUG : m7tnlcgevcrm559nd6mctfirjnmcu6c8esth5esmcba052hqqk5vpav73h5i453353ndsjkbqvbq5n13fpbveqi0gm2j0ljlqdg9l3qv2h2lj9mrrt0mpd5ulebr49svbtbh2jmifsdgu5ha8e16nc6q240qjaufap950lu4b3a3e7dvj5demeqc52d9cp8t5cfj77a0tjbmmjq9m0ta21jqne22qp58l5htbqh4cnjrshrd8g21k5cuptoprum: Skipping undecryptable file name: not a multiple of blocksize
2022/09/12 16:50:22 DEBUG : 2 go routines active
>

So it appears there are two files that rclone is ignoring that exist in the directory it claims it is removing, yet it is still not removing the directory when rclone sync is used, and is not providing any warning or error messages about the removal failing without -v being used.

Attempting to purge these directories manually seems to work:

> rclone purge -v odc:audio/work/new/waiting/Johann_Sebastian_Bach_Canadian_Brass_-_Art_Of_The_Fugue
>

And a repeated purge shows that the directory is actually gone now:

> rclone purge -v odc:audio/work/new/waiting/Johann_Sebastian_Bach_Canadian_Brass_-_Art_Of_The_Fugue
2022/09/12 16:58:37 ERROR : Attempt 1/3 failed with 1 errors and: directory not found
2022/09/12 16:58:37 ERROR : Attempt 2/3 failed with 1 errors and: directory not found
2022/09/12 16:58:37 ERROR : Attempt 3/3 failed with 1 errors and: directory not found
2022/09/12 16:58:37 Failed to purge: directory not found

What is your rclone version (output from rclone version)

rclone v1.59.2-beta.6379.603efbfe7

  • os/version: debian 11.4 (64 bit)
  • os/kernel: 5.10.0-17-amd64 (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.17
  • go/linking: dynamic
  • go/tags: none

Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

Debian 11.4

Which cloud storage system are you using? (e.g. Google Drive)

Opendrive with crypt remote

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.

Activity

  1. eharris commented on Sep 12, 2022

    @eharris
    ContributorAuthor

    I believe this also points out a problem with sync that it allows files that it is "ignoring" to remain existing and un-reported even though sync should remove any files that are not on the source, even if they are not readable for some reason.

  2. animosity022 commented on Sep 13, 2022

    @animosity022
    Contributor

    That's because you are mixing crypt and non crypt.

    Fix your remotes so they don't mix..

  3. eharris commented on Sep 13, 2022

    @eharris
    ContributorAuthor

    @animosity22 that is beside the point. sync should make the destination identical to the source, and should delete any files and directories that do not exist on the source, whether they are crypted or not. In this case, sync is not doing that.

  4. eharris commented on Sep 13, 2022

    @eharris
    ContributorAuthor

    And as an aside, these leftover files were at some point created by rclone, as this remote has never been touched as non-crypt. I haven't been able to track down why yet, but when I do I'll be filing a bug on that as well. I think it has something to do with exceeding the storable cryptable filename length.

  5. animosity022 commented on Sep 13, 2022

    @animosity022
    Contributor

    If the file name is too long, you get a message stating such as that's an easy one to produce.

    The use case here is at some point, you probably accidentally copied from a non crypt location to a crypt location by mistake.

  6. eharris commented on Sep 13, 2022

    @eharris
    ContributorAuthor

    @animosity22 that is a presumption without any evidence on your part, and I'm stating that that's not the case. I merely offered the info to dispel your presumption, even though it is off topic to this bug report.

  7. animosity022 commented on Sep 13, 2022

    @animosity022
    Contributor

    Isn't yours a presumption too as there's no evidence? :)

    I'm just sharing what I've seen over reading tons of posts, debug logs, etc. The only time I've seen that use case is by an accidental copy from a non crypted remote to a crypt location in a remote.

    That's my "theory" which has no malice, ill will, bad intent or anything else.

    Could there be a bug? Sure. Could I be incorrect? Sure. I'm sharing my thoughts based on my experience.

  8. eharris commented on Sep 13, 2022

    @eharris
    ContributorAuthor

    This is not an enhancement, it is a bug. Please mark it as so, since it clearly a violation of the stated operation of sync. There is an exception made in the documentation for duplicate objects, but that is not the case here (directory vs files with errors).

  9. animosity022 commented on Sep 13, 2022

    @animosity022
    Contributor

    It's really an enhancement as garbage in there isn't a bug but a flow issue or a bug somewhere else per your message if something else caused it but the label really doesn't matter than much imo so I changed it.

  10. soredake commented on Feb 24, 2024

    @soredake

    Same problem but with mirroring folders on local filesystem.

  11. added a commit that references this issue on Feb 29, 2024
    4c6d2c5
  12. lnostdal commented on Apr 26, 2024

    @lnostdal

    Surely this is not fixed? If I delete a directory on the remote, sync fails to remove the same directory at the target. Things like --ignore-errors don't help.

    I tested with latest release. Using a HTTP source and local target directory.

  13. nielash commented on Apr 30, 2024

    @nielash
    Contributor

    Using a HTTP source and local target directory.

    The original issue here was regarding crypt failing to remove directories due to ignored non-crypt files present in the directory. It sounds like your issue is slightly different. I'd suggest opening a new issue and including a DEBUG log that shows the problem.

    See also #7720

  14. added a commit that references this issue on Jul 20, 2026
    127731f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions