Use case: “Automatically Empty Trash after each scan” is on but media is on network file share. The feature I am suggesting would prevent media from being “trashed” by mistake when the media is unavailable for some reason.
How it would work: The Empty Trash job would validate the read access to the media folder using the path in the Library settings (e.g. /movies ) and skip the library if any library folder is not read accessible. This test can be tricky since the folder may exist but the volume may not be mounted ( in the case of Linux ).
The test might be that you can read at least file from the share.
But what if the user deleted all of the media files and wants the titles to go to the trash?
I can’t think of an easy solution. You can put a notice in the interface that automatic trash processing will not run if all movies have been deleted. The must be at lease one movie left so that the read test can succeed.
Prompt: I recently discovered that my movie library was practically empty. I scanned the files again and it re-discovered the movies. Not only that, but seems to have keep watched status as well. Nice. However, I noticed that the playlists weren’t deleted but they were all empty! I was able to restore a 2- week old database backup and get the playlists restored.
I’ve turned of the automatic trash emptying feature and will manually do it for now. Please consider my feature as it will give users the best of both worlds. Automation without losing data.
Plex is already doing that.
If the file share or drive is not accessible at all, Plex considers it as “temporarily unavailable” and doesn’t trash the media.
However, this safety mechanism is cancelled if you don’t point Plex directly to a file share or traditional drive.
If you for instance use “directory junctions” on Windows to mount a whole different drive to what looks like a simple subfolder of your main drive, then Plex cannot tell the difference between a lost drive or a genuinely empty folder.
Example:
D:\Movies <- Plex library points here
\Movies 1\ <-- regular subfolder, containing movies
\Movies 2\ <-- additional hard drive is mounted here
In the above case, Plex simply assumes that the subfolder Movies 2 is empty, if the additional hard drive which is mounted there gets out of order.
Because the hard drive D: (where the library points at) continues to be available.
Interesting. This was my explanation for why around 1200 movies disappeared from my library. Running another scan found them and added them back in. It didn’t trust that watch status and miscellaneous fixes that had I done to the library were still there, so I restored it from a Plex db backup.
Plex Media Server is pointed at SMBv3 shares ( 1 per library ) on my Synology NAS. Plex Media Server itself is running natively(not docker ) on a 2019 Mac Mini. The mount locations are “~/mounts/”
e.g. “~/mounts/movies” for the movies library
and maintained by an app called “automounter” that keeps shares mounted as best as is possible.
I wonder what happened then. I’ll probably never know, It did teach me how to restore .db files, so it wasn’t entirely a bad experience.
I don’t use Windows, but the information about junctions might help someone with a similar issue but is using Windows. +1 for providing it.
Otto’s comments about junctions are relevant to macOS mounts as well. Windows “Junction” mounts are similar to other operating systems that don’t use drive letters.
Expanding on the protection mechanism -
If a top-level Library Directory is completely empty the protection is engaged and Plex won’t delete everything in the Library.
If a Library Directory contains any files or directories, the protection isn’t engaged.
Brainstorming a possible cause for your issue -
macOS allows filesystems to be mounted on non-empty directories.
If you have any files in ~/mounts/movies on your local drive when the share isn’t mounted, the Plex “Missing Volume” protection mechanism would have seen those local files, and would not have protected you.
I think Empty trash automatically after every scan should be off by default.
The folders are empty. The way automounter works is I created folder called /home//mounts and I tell AutoMounter to mount smb/nfs share underneath that folder. The application does its magic so that ~/mounts/movies is created. It has a number options such as actions it can take or scripts it can run when the share is mounted or unmounted. It’s a neat app. More importantly, I don’t create any folders underneath the “mounts” folder, so there are definitely not any files there when the share is not mounted.
The library folder doesn’t exist in that case.
I forgot to mention that I previously had the automatically empty trash enabled. I learned my lesson and disabled it. I manually empty trash now after verifying the shares are mount and a library file scan has completed. No more risk taking for me!