Change in 'Trash' Behavior - unexpected library item removal

Server version #1.20.1.3252
FreeBSD/FreeNAS

[Edit: removing some incorrect guesses.]

I just saw the trash be emptied unexpectedly. I’ll do more investigation later and compare with the previous version of PMS.

I added new-and-improved files, with different filenames, for a few existing movies. I moved the old files away so Plex couldn’t see them any more.

I scanned the library, and the movies all appeared as “Duplicates”, as expected. Both sets of media files, the reachable and unreachable ones, were linked to the movies. The movies appeared in the new “Trash” filter view.

Then I scanned again, and all of the duplicates were gone. Only the new files were present.

It was as though I had emptied the trash.

Empty trash automatically after every scan is unchecked. I didn’t empty trash manually.

Hopefully I just did something stupid and this is a false alarm. :slight_smile: Will report back.

Yes, something is wrong. Trash is being emptied when it shouldn’t be. Eep!

It takes multiple movies to trigger this behavior. I also reverted to 1.20.0.3133 and it still occurs. Perhaps it is a new Agent or new Scanner issue.

I can reproduce it consistently with this:

Empty trash automatically after every scan disabled.
Create a new directory for a test library.
Create a new library in Plex.

mkdir "Back to the Future (1985) [tt0088763]"
dd if=/dev/urandom bs=1024k count=101 of="Back to the Future (1985) [tt0088763]/Back to the Future (1985) [tt0088763].mp4"

mkdir "Ghostbusters (1984) [tt0087332]"
mkdir "Real Genius (1985) [tt0089886]"
mkdir "Top Gun (1986) [tt0092099]"
dd if=/dev/urandom bs=1024k count=101 of="Ghostbusters (1984) [tt0087332]/Ghostbusters (1984) [tt0087332].mp4"
dd if=/dev/urandom bs=1024k count=101 of="Real Genius (1985) [tt0089886]/Real Genius (1985) [tt0089886].mp4"
dd if=/dev/urandom bs=1024k count=101 of="Top Gun (1986) [tt0092099]/Top Gun (1986) [tt0092099].mp4"

Scan Library Files. Movies appear.

Now delete 3 out of the 4 movie files:

rm "Real Genius (1985) [tt0089886]/Real Genius (1985) [tt0089886].mp4"
rm "Top Gun (1986) [tt0092099]/Top Gun (1986) [tt0092099].mp4"
rm "Ghostbusters (1984) [tt0087332]/Ghostbusters (1984) [tt0087332].mp4"
rmdir "Ghostbusters (1984) [tt0087332]"
rmdir "Real Genius (1985) [tt0089886]"
rmdir "Top Gun (1986) [tt0092099]"

Scan Library Files again.

Everything looks as expected now. Files are Unavailable for 3 movies, and they have Trash icons.

If you Scan... again, it stays like that, as expected.

Now Analyze and/or Refresh All Metadata the library. It doesn’t look like anything has changed, but this is necessary to reproduce the issue.

The next time you Scan... (after Analyze/Refresh) two of the movies with deleted files are gone, as though the trash was partially emptied. It’s unpredictable which ones are gone. One movie randomly remains.

Another time, a different movie remained:

1 Like

I tried this on my test server (Plex official Docker, 1.21.1.3252) and see similar behavior (the only difference is the number of movies which are perma-deleted).

Before:
image

After refreshing all meta data, deleting Ghost Busters, Real Genius, and Top Gun’s directories and files, and re-scanning the library:
image

It also doesn’t appear to be a cosmetic issue. I changed the posters for all of the movies beforehand. If I don’t empty the trash manually and then add the files back, the ones which showed the trash can retain the updated posters; the one that did not came back with its default poster:
image

1 Like

Thanks for validating & confirming! It’s always nice to know one isn’t alone, especially with a weird behavior bug/regression/defect/something.

Agreed. The library item & metadata seem to be gone, not just the media references.

1 Like

If this is a library which was converted to the new Plex Movie agent, make sure to Refresh Metadata of those items before you remove the files and before you add the new files.

On top of that: Never remove the old files before you have added the new files and have started a library scan.

This wasn’t a migrated library, this was newly created for testing.

I first noticed this because I had upgraded media files, and was surprised that Plex removed references to the old files without an Empty Trash step.

As I investigated I became very surprised when Plex completely deleted library items & metadata without Empty Trash being performed explicitly.

Every reference to the trash in the documentation seems clear:

https://support.plex.tv/articles/200289326-emptying-library-trash/

https://support.plex.tv/articles/200289526-library/
Disabling this option keeps the item in the library with an indicator superimposed over the item’s poster when the item is removed.

I am 95% sure that this is a change in behavior. It does not make sense that Analyze ... and then Scan ... would partially and non-deterministically empty the trash.

I’m fetching 1.19.5.3112 to compare now. I think I’ve seen this same behavior on a TV library, I’ll confirm that too. (Edit: Yes, media items are removed from TV libraries in 1.20+ also. This isn’t limited to the new Movie scanner.)

If I’m wrong and this isn’t a change, I’m still very surprised by the behavior. When Empty trash automatically... is disabled, I don’t expect to lose library items and metadata unless I explicitly empty the trash.

This behavior has changed since 1.19.5.3112.

I installed 1.19.5.3112 and followed the same steps as above. Then I scanned, analyzed, refreshed, scanned, refreshed, analyzed. I could not trigger this.

In 1.19, unless Empty Trash was performed explicitly, missing media items were not removed. Neither were library items and metadata.

1 Like

My test library wasn’t migrated either. It was in fact a brand new library created expressly to test this, using all defaults in the advanced settings.

I added four movies to the library and ensured they were indeed matched (Fix Match present in the more menu, Unmatched filter in the library view empty). I then refreshed all metadata for the library, deleted all but Back to the Future’s files and directories from the library directory, and then performed a new scan. The results are what you see above; Back to the Future is still in the library normally, Ghost Busters and Top Gun show with trash indicators, and Real Genius is just gone.

I’d be very surprised if this is the expected behavior as well.

Thanks for the info on this, I wish I had seen this forum thread earlier.

I can confirm this is a regression caused by a different fix to recompute the file hashes on an analysis. A fix is already submitted and will be in the next release.

2 Likes

This appears to be resolved. Thanks!

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