How to get full directory tree cached on first mount?

That setup is perfect.

Firstly, the most important part is that have a backend that supports polling. Without this would be very hard to have any sort of practical preaching while also being able to detect changes on the drive.

Secondly, my primary OS is also Windows, so you can just use my scripts with very little modification necessary.

So in short our process will be:

  • Set required flags to keep cache information long-term
  • As part of the mounting script, start a process that precaches the disk (I will share script)

These are the relevant flags:
--attr-timeout 8700h ^
(how long to keep information about files, like size, modtime ect.)
--dir-cache-time 8760h ^
(how long to keep directory information, list of files in a folder)
--poll-interval 30s ^
(how often to ask the Google server is anything on the drive has changed and needs to be also changed in the cache)
We will simply append these flags to your regular mount command.

So now I will share some batch scripts that you can modify to your need. Here is a simple example of how to mount a drive, and also call the precache script at the same time:
Note that you don't need to use all, or any the flags I do (except the 3 mentioned) - but I will leave them in to illustrate and you can ask more about them if interested.

Mountscript.bat

@echo off

::Variables
set driveletter=X
set remotename=TD1Crypt
set RCport=5572

::Window size (bootup)
mode con: cols=60 lines=20
title %remotename%-BOOTUP
cd c:\rclone

echo Spawning mount for %driveletter%: (new window)
echo.

:: Now let's mount the drive with some options
start /min "%remotename%" rclone mount %remotename%: %driveletter%: ^
--rc ^
--rc-web-gui ^
--rc-addr localhost:%RCport% ^
--rc-user test ^
--rc-pass test ^
--cache-dir "E:\!---Rclone_VFS_Cache" ^
--vfs-cache-mode writes ^
--vfs-cache-poll-interval 20m ^
--vfs-cache-max-age 8760h ^
--vfs-cache-max-size 1024G ^
--attr-timeout 8700h ^
--dir-cache-time 8760h ^
--poll-interval 30s ^
--allow-other ^
--multi-thread-streams 0

::Start cache warmup
call VFSCacheWarmup.bat %driveletter% %RCport%

The only thing you should really need to change here is:
set remotename=TD1Crypt
(use the name of your own remote here)
cd c:\rclone
(change this if you have rclone somewhere else)
--cache-dir "E:\!---Rclone_VFS_Cache" ^
(assuming you want to use write-caching at all, then set a folder here for temporary files)

As you might notice, at the end we also call another script, so you will need to make that too (in this example you would put it in the same fodler as the other script to make it work):

VFSCacheWarmup.bat

@echo off

::Variables
set driveletter=%1
set RCport=%2

:: Check that the folder is valid, otherwise wait until it is
echo Waiting for %driveletter%: to be ready ...

:LOOP1
vol %driveletter%: >nul 2>nul
if errorlevel 1 (
    echo " "| set /p dummyName=.
	timeout /t 1 > nul
	goto LOOP1
) else (
	echo.
    echo Drive %driveletter%: OK!,
)

echo.
echo Warming up cache...
echo This may take a few minutes to complete
echo You can use the cloud-drive normally while this runs
echo.

echo Awaiting completion-message from RC...
rclone rc vfs/refresh -v recursive=true --rc-addr localhost:%RCport% --rc-user test --rc-pass test > nul

::If exit code of above command was anything but normal (indicating an error) - trigger alarm and pause for diagnosis.
if not %ERRORLEVEL% equ 0 (
	echo Something went wrong during precaching. Is the mount still running? press any key to continue.
	pause
) else (
	echo Cache warmup for %driveletter%: OK!
)

echo Closing window in 5 seconds...
timeout /t 5 >nul

You should not need to change anything in this file. Just make sure to name it as suggested and put it in the same folder as the other script.

Finally - to run the whole thing - just double-click the mountscript. You might also perhaps want to run this automatically as soon as you log in ect. but that is another topic for another day :slight_smile:

Let me know if you have trouble with any of this and I will get you settled.

8 Likes