I have added --trash-dir
flag when we performed rclone mount
.
What it does?
Basically, when this flag is mentioned, it will not performing destruction operation in the server side. Instead, it will overriding deletion with move (rename) operation to the trash directory.
Suppose that you have /mnt/mymount/
from command
rclone mount remote: /mnt/mymount/ --vfs-cache-mode=writes
Then, you performed:
rm -rf /mnt/mymount/myfile.txt
If your remote side didn't allow destruction operation, you will have this message:
2019/12/06 14:11:48 ERROR : Attempt 3/3 failed with 2 errors and: googleapi: Error 403: The user does not have sufficient permissions for this file., insufficientFilePermissions
But, if your mounting options is using --trash-dir=.trash
:
rclone mount remote: /mnt/mymount/ --vfs-cache-mode=writes --trash-dir=.trash
Then, when you performed:
rm -rf /mnt/mymount/myfile.txt
The rclone backend will performing rename/move operation into remote:.trash
.
So, you will see /mnt/mymount/myfile.txt
moved to /mnt/mymount/.trash/myfile.txt
.
Therefore, this is useful in the OS side, which doesn't care about the remote side limitations. So, OS side can perform destruction while it created illusion in the remote side where it's just moving the file.
Here is the log sample of performing deletion which is actually moving:
2025/07/03 03:13:26 DEBUG : /: Lookup: name="bla.txt"
2025/07/03 03:13:26 DEBUG : /: >Lookup: node=bla.txt, err=<nil>
2025/07/03 03:13:26 DEBUG : bla.txt: Attr:
2025/07/03 03:13:26 DEBUG : bla.txt: >Attr: a=valid=1s ino=0 size=28 mode=-rwxr-xr-x, err=<nil>
2025/07/03 03:13:26 DEBUG : /: Remove: name="bla.txt"
2025/07/03 03:13:26 DEBUG : bla.txt: Remove:
2025/07/03 03:13:28 DEBUG : Added virtual directory entry vAddDir: ".trash"
2025/07/03 03:13:29 INFO : bla.txt: Moved (server-side) to: .trash/bla.txt
2025/07/03 03:13:29 INFO : bla.txt: vfs cache: renamed in cache to ".trash/bla.txt"
2025/07/03 03:13:29 DEBUG : .trash/bla.txt: Updating file with .trash/bla.txt 0xc001ad5d40
2025/07/03 03:13:29 DEBUG : .trash/bla.txt: Moved to trash: .trash/bla.txt
2025/07/03 03:13:29 DEBUG : bla.txt: >Remove: err=<nil>
2025/07/03 03:13:29 DEBUG : /: >Remove: err=<nil>
Here is my forked repo where it's modified the source code that has added the feature:
You can find the binary release which is not optimized yet at the repository.
Note that, all changes are made by Agentic AI by Github Copilot Claude 4, I never use GO language before. So, you can say that I was being a vibe coder.