How to Delete Files/Folder inside the Mount Location before Mounting?

Hello! I wish to have a script command which would delete the Files/Folders inside the Google Drive Mounting Location for the rclone mount.

rclone mount command: rclone mount --allow-other --buffer-size 256M --dir-cache-time 96h --timeout 1h --default-permissions --uid 99 --gid 100 --umask 002 --vfs-cache-mode full --vfs-cache-max-age 24h -v --progress --cache-dir /mnt/disks/ua_hdd1/rclone/cache gdrive: /mnt/disks/ua_hdd1/gdrive &

Now, I wish to delete the files/folders inside /mnt/disks/ua_hdd1/gdrive before I run the rclone mount command.

I have a bash script which runs the rclone mount command each time I restart the server. So I am thinking to add that delete command in the same bash script before the rclone mount command.

But make sure it doesn't delete anything after rclone is mounted.

Reason: This --allow-non-empty doesn't work.
Error: 2021/03/01 20:31:27 Fatal error: Directory is not empty:

P.S.: I have not followed the Bug Format because it is not a bug rather a simple help request post.

Thanks.

DEFAULT HELP REQUEST FORMAT IS ADDED ON THE REQUEST OF @Animosity022

What is the problem you are having with rclone?

To be able to delete the files/folders inside the mount location before rclone mount command is run. But --allow-non-empty option doesn't work as expected.

What is your rclone version (output from rclone version)

1.54.0

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

Unraid 6.8.3 (Lastest Stable)

Which cloud storage system are you using? (eg Google Drive)

Google Drive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone mount --allow-other --buffer-size 256M --dir-cache-time 96h --timeout 1h --default-permissions --uid 99 --gid 100 --umask 002 --vfs-cache-mode full --vfs-cache-max-age 24h -v --progress --cache-dir /mnt/disks/ua_hdd1/rclone/cache gdrive: /mnt/disks/ua_hdd1/gdrive &

The rclone config contents with secrets removed.

[gdrive]
type = drive
client_id = xxxxxxx.apps.googleusercontent.com
client_secret = xxxxxx
scope = drive
token = {"access_token":"xxxxxxx"}
team_drive = xxxxxx
root_folder_id = 

A log from the command with the -vv flag

2021/03/01 20:31:27 Fatal error: Directory is not empty: /mnt/disks/ua_hdd1/gdrive If you want to mount it anyway use: --allow-non-empty option
Script Starting Mar 01, 2021 20:38.01

Unraid Forum Comment on Waseh's rclone Thread: https://forums.unraid.net/topic/51633-plugin-rclone/?do=findComment&comment=953846

It's best to make the proper dependencies on your startup as adding a delete script is not really addressing the issue.

You want to find what is starting before your mount and add the proper requirements to the service file so it starts after.

The help request is there as it collects details.

It says what OS are you running.
It says what version you are running.

It provides some details on what to do and formats things proper. While it's a simple question, I can quickly answer it with specific details depending on what's provided rather than going back and forth.

1 Like

Hi, Thanks for the prompt reply, I have added the Default Format of the Details Collection in the Opening Post. Please check.

Since I am running Unraid and rclone runs with the server and other applications such as Sonarr/Radarr works in the Docker, I cannot control it.

Because if rclone was running in docker, I could have prioritized running rclone before Sonarr/Radarr.

Hence if there is some other way to achieve it or if you know anything?

Only if --allow-non-empty was working fine, I wouldn't be requiring any solution to be honest. :frowning:

Thanks.

That would be the worst thing you could do as it allows over mounting.

If something starts before rclone and it writes to the mount, you'd hide it by 'over mounting' with allow non empty so you'd be writing things locally causing your local disk to fill up.

There's no way to control order of operations in Unraid? That seems odd.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.