Repository navigation
Description
What is your current rclone version (output from rclone version)?
rclone v1.66.0-DEV
- os/version: debian 12.5 (64 bit)
- os/kernel: 6.1.0-14-amd64 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.21.8
- go/linking: dynamic
- go/tags: cmount
What problem are you are trying to solve?
rclone often leaves "broken" (orphaned) files or directories around in cloud storage because of errors in some lower layer.
These files are often not easy to notice/detect, and even harder to cleanup, potentially causing errors or even effectively breaking the intent of an operation (e.g. sync, which should make a destination exactly match the source, removing or replacing any files that are errored).
How do you think rclone should be changed to solve that?
I looked into the cleanup command, but this only seems to affect storage engines that have some sort of intrinsic cleanup (like emptying the trash) and doesn't do anything for errors within layers of rclone itself.
See also: https://forum.rclone.org/t/chunker-on-wasabi-removing-aborted-upload-orphaned-chunks/28911/8
At a minimum, there should be some way to force deletion of any files or directories in a remote that cause an error.
Some examples of this are:
- Files/dirs in a crypted remote that have undecryptable names
2024/04/03 08:06:12 NOTICE: g9st70d4o7gu8gku144ehe2c20/jqb9ff83opna7s7q8e3pg5d60k/e6n32nt2582pt7lh92v5ba2ccfeh06juk05k4gego30rrie6quar40rv4okproo28opkqilrevl0irngshqq3vricu5faaksfmme7g4bvpft1275hl9nl31jg51gdua6/t1o76c54r466mf6rhbnc7j2455eqnrpnk8k2f4h3gr6254lbjkindp5o7mnhf0ibq6u1s2142t5fpiik7tmsl0tg8i2gjj28gjg4b2k07u4h8bot366i21v0un40jmvj25ononf6hhumn83o72dqedk1hi02id40fspg0dldru68a7ub69n3ev9sgc9ombbdgi5erg8c5fjh2dv23un19rl3hbfqkhib8gugustn6g0es1sc2196u8gn2g9ubtv: Skipping undecryptable file name: not a multiple of blocksize
- Orphan files in chunked remotes that have been left around from prior errors (these seem to be invisible to the chunker layer, but are left as orphans in the underlying storage layer)
54096 2024-03-30 15:04:26.000000000 somefile.rclone_chunk.001_6l9trf
Perhaps an added --cleanup or --delete-errored flag for most/all commands that will cause any files encountered that result in errors to be deleted? This flag/operation should be propogated down to any lower layers.
Better would be some way to move any broken files/dirs to a particular location so as to be able to more easily investigate them and/or delete them.
Even better would be to make rclone sync or other operations where it is the obvious intent actually do this cleanup automatically. For reference, see #6437 which was closed as completed even though the problem remains.
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
nielash commentedon Apr 30, 2024
I tend to agree with you that deleting would be the "correct" behavior when the undecryptable file is on the dest during a
sync. I didn't go that far with the PR for a few reasons:cryptbackend is not aware of when it is acting as a source vs. a dest, so it would actually be pretty tricky to make it delete files only when acting as a dest. It would be easy to make it delete them always, but then that verges on a different kind of incorrect, assyncis not supposed to delete anything from the source. Likewise,copyis not supposed to delete anything at all, andcryptis blind to whether the caller issyncvs.copy.I like your idea of a
--delete-erroredflag that deletes garbage whenever it's encountered. It wouldn't be terribly difficult to implement that forcrypt.eharris commentedon Apr 30, 2024
In my opinion, this is a concern of no importance, at least as far as errored files on the destination. A
syncoperation is clearly intended to make the destination match the source, and removing any spurious destination files (including errored ones) is clearly within that intent. If the operation is a sync, and the file/dir doesn't exist on the source, then it should get removed on the destination, full stop. If someone wants to embed non-crypt data within a crypt sync destination, then it's reasonable to expect to have to to add--excluderules to deal with that (although I admit I'm not exactly sure how that would/should work).I also don't think this is a valid concern, as the default for deletions is
--delete-after, so no data will be lost since any potentially errored files that exist on the source would already have been replaced before deletions occur. If the user has chosen a different deletion behavior, then they got what they asked for. And if they want to be super safe, they can always use--max-delete 0, or they should do the normal (and often recommended) precaution of running with--dry-runbefore they actually run their command to make sure it's doing what they expect.I totally agree that deleting errored files always (regardless of whether they are on the source or destination) is problematic, and I would not support such a solution unless it is protected by a separate and non-default flag to enable it.
However, the difficulty of implementation doesn't change the fact that for a
syncoperation performed on a destination with extraneous files (including errored ones), the only proper behavior is that they should be removed.I did not intend for my suggestion of
--delete-erroredto apply to the source, since that would be unexpected and potentially quite dangerous. As an example, would a file that is unreadable be considered an error? While it isn't necessarily common to have files that are able to be deleted by a user that cannot read them, this is certainly possible (via acl's, SELinux policy, etc), and this could easily cause unexpected data loss if applied to the source.I would never expect that the source of an operation would be modified under any circumstances unless the clear intent of the operation is to do so (e.g.
bisync).nielash commentedon Apr 30, 2024
You make good points here, and it's hard to argue with them because in principle I agree with them.
I think ultimately it is @ncw's decision, and if @ncw thinks it's a good idea, I am happy to work on a PR that treats undecryptable dest files like any other missing-on-src file. I have some ideas about how it could be done -- it would be tricky, but not impossible.
eharris commentedon Aug 19, 2024
@ncw care to weigh in here?
eharris commentedon Oct 14, 2024
Attempting to ping @ncw again...