Is there a way to tell RClone not to delete a file if it's in use, and to keep checking until it's not in use to delete?
I have the following set up
/mnt/files1 (Rclone Mount)
/mnt/files3 (2nd Rclone Mount)
/mnt/files3 (MergerFS of the above mounts)
Now when a file is in use in /mnt/files3, Rclone deletes it from the /mnt/files1- causing the file in use to error out.
Is there a way to make Rclone only delete a file if it's not being used, and if it is being used, keeo checking until it's not in use anymore, and then delete it?
I run two servers. 1 for downloading and post processing with Sonarr/Radarr, and one for Plex streaming.
The downloading server uploads post processed files to two seperate Rclone folders (one a tdrive the other a gdrive)
I then have a seperate machine running Plex, with the above folders Rclone mounted, and then merged with MergerFS.
What is happening is when Sonarr/Radarr updates a file, it deletes the existing file, then uploads the new file.
Problem is, when it deletes this old file, its removed from the MergerFS mount on the Plex server, even if it's being played. So the playback errors out.
It you prevented the file being deleted, that would break the Sonarr/Radarr flow though.
If the machines are remote, you'd have to do something like a check file or something to show the file was being used and that feels ugly too.
In your case machine A running Sonarr/Radarr would never know machine B is playing something as it's a completely different mount so A would show no use as it's B playing it.
Maybe someone else has a better idea on how to solve that. I've never hit that particular item myself, but I don't keep quality with names so it replaces with the same name.
Yeah I'm happy for the file to be deleted/renamed on the Sonarr/Radarr side straight away, but don't want the file to be deleted/renamed on the Plex server mount whilst it's being played back.
Then once playback has been completed and the file is no longer in use, Rclone then makes its change in the Plex side mount.
There isn't a concept of in use really though for the mount as you are not running a command to delete it as it's done by polling since it was deleted on a remote machine.
It detects a change based on your polling interval and processes those changes that come in. By default, they are every minute.
Not quite sure how it handles a file that is gone from the remote in terms of continuing to stream it. I'd surmise it would break eventually if the source on the provider was gone, which might be what you are seeing? You could test by having a large poll interval and delete something see if it continues to play.
Are you using qualities or changing the names? I'd guess the playback would break if the client requested a file that isn't there anymore as the client side might not have updated.
I started playback of a file on Server 2 (Streaming Server)- deleted the same file from Server 1 (Downloading Server), and Server 2 could no longer access that file.
It reached the point where it had transcoded ahead (a minute or so), then froze. You could see Plex trying to transcode the file more but it couldn't, because it didn't exist anymore.
I'll do some more testing tomorrow- but it seems Rclone never provided Plex with the full file before Rclone triggered the delete.
This issue will affect anyone that runs Plex on a separate server from their Sonarr/Radarr server.
If you have a file and you are playing it, it'll stay there until the file is closed even if you delete it along the way.
If you have a file delete a file and something tries to access a file no longer there, it doesn't work because the file is gone. It isn't a rclone thing as your scenario would occur with a local file system as well.
If you delete a file being played and Plex has closed the file and tries to reopen it, it won't work. It's not rclone related as it is file access and deleting files.
Yeah I understand what you're saying. My only thought is Plex closes off the file when it reaches the "throttle transcode" threshold. Then tries to open the file again when it needs to transcode. Can't find the file and errors.
One way to potentially get around this is to set the transcode buffer to a much higher level, so it never throttles the transcoder.
If my family lets me I'll have a play with some logs tomorrow. What logs should I look at, rclone debug logs?