How does VFS cache resume upload in case of crash? (mechanism)

Hey all,

For the benefit of understanding the system better and reducing potential risks - what safety-measures do the VFS have to ensure that once a file reaches it's (write) cache it does not get lost if rclone or the whole system suffers an unexpected failure?

Hypothetical scenario:
You move a large file to the cloud via mount. It finishes copying to cache and is deleted from it's original position. Upload starts - but before it can be finished an unexpected power outage happens (or let's say rclone crashes or is forcefully shut down without checking if active transfers is happening). When power is restored the system is powered on and rclone is launched and cloud drive is mounted again.

In this scenario, how does the VFS now know that it needs to resume the upload of the file it has in the cache? How does it distinguish it from stale files (trash) that have already been processed? If it doesn't then the file will eventually be lost next time the cache flushes, which could be a disaster. If it keeps track of this in some stateful way, then where is this information saved?

I hope someone can enlighten me :slight_smile: