Bug: Plex scanner may ignore or destroy directory depending on contents

I’ve changed “ALL” to “Unmatched”, the result is “The active filter has no matches”. I will look into WebTools-NG, but as far as I can tell the episodes are not showing up in plex at all, not een as inmatched

Additionally I tried searching by duplicate episodes among other things, no luck:

@ChuckPa I couldn’t find any unmatched or duplicate episodes on my plex library. As for WebTools-NG (this is a cool tool), I assume you were referring to the “Find Media” option? This did not show these files at all. But I can see them present on the drive via ls as demonstrated above.

Then perhaps your medias might be identified as different shows?

Try in the Web-client to switch from shows to folder view, and navigate to the folder

I do not think so. I used tautulli to test the number of shows/seasons/episodes in the library before and after adding it, the number does not change. All three numbers do change if I remove or add other shows.

@dane22 The folder does not show up in the folder view.

I could see in the logs the show was detected upon the initial scan, and I believe it also matched because it grabbed metadata and the names properly. But after the rescan I can see it ‘destroyed the metadata items’, ‘deleted the media items’, ‘removing 2 directories that were left’ (just to be clear, the media files themselves are untouched so I assume this removal was of some files internal to the data plex. So I know it did detect them properly and could even read them since it started analyzing them and all. The issue is that after moving them into the library, after the initial scan, subsequent scans seem to remove the files entirely from plex. Tautulli shows the number of shows/seasons/episodes to be what it is without them, the folder doesn’t show up in the folder view, etc.

Disable emptying of the trash when scanning, That way plex will not remove stuff during a temporary issue.

Just saw this, and can only conclude, that you might have a rights issue, since WT-NG SHOULD pick it up

@dane22 After the initial scan, I can view the files and watch them as usual; so I don’t think it is a permissions issue since it does work just fine at first. They disappear after the second scan. Also, the permissions are the same as every other media file. From above:

$ ls -laR .
.:
total 0
drwxrwxr-x 1 sonarr sonarr    18 Nov 30 10:52  .
drwxrwxr-x 1 sonarr sonarr 37596 Nov 30 10:50  ..
drwxrwxr-x 1 sonarr sonarr  2050 Nov 30 10:46 'Season 01'

'./Season 01':
total 9065380
drwxrwxr-x 1 sonarr sonarr      2050 Nov 30 10:46  .
drwxrwxr-x 1 sonarr sonarr        18 Nov 30 10:52  ..
-rw-rw-r-- 1 sonarr sonarr 754118524 Nov 17 06:45 'Chivalry of a Failed Knight - S01E01 - The_Worst_One_I-[Sonarr-Bluray-1080p].mkv'
...

I also tried chmod and chown ing them both again just in case in the past. For reference, these are the rights on my other files which work just fine:

$ ls -laR .
.:
total 0
drwxrwxr-x 1 sonarr sonarr    18 Jul  9 05:18 .
drwxrwxr-x 1 sonarr sonarr 38054 Dec  1 09:39 ..
drwxrwxr-x 1 sonarr sonarr  1650 Sep 25 12:49 Season_01

./Season_01:
total 12907840
drwxrwxr-x 1 sonarr sonarr       1650 Sep 25 12:49  .
drwxrwxr-x 1 sonarr sonarr         18 Jul  9 05:18  ..
-rw-rw-r-- 1 sonarr sonarr 1464121124 Jul  9 05:18 'Zom_100-_Bucket_List_of_the_Dead-S01E01, Akira_of_the_Dead-[SubsPlease-WEBDL-1080p].mkv'
...

As you can see, the ‘trouble files’ have the same rights working files.

Additionally, in the past I did sudo cp -a 'Chivalry of a Failed Knight - S01E12 - Another_One-_The_Uncrowned_Sword_King_II-[Doki-Bluray-1080p].mkv' 'Chivalry of a Failed Knight - S01E13.mkv' (creating a fake episode 13). Once more this series was detected and I could see it being analyzed by plex in both the dashboard in logs; but after the new scan the series (and fake episode) vanished again.

Also, plex is capable of hashing the files it seems as well, which should mean it can read them just fine I would imagine. This is from the logs:

Nov 21, 2023 00:50:44.326 [140261836524344] DEBUG - We found a hash match for [/anime/Chivalry_of_a_Failed_Knight-{tvdb-299506}/Season_01/Chivalry_of_a_Failed_Knight-S01E13.mkv] which was [/anime/Chivalry_of_a_Failed_Knight-{tvdb-299506}/Season_01/Chivalry_of_a_Failed_Knight-S01E12, Another_One-_The_Uncrowned_Sword_King_II-[Doki-Bluray-1080p].mkv].

When you added the match file, did that also have the same ownership and rights?

The .plexmatch file? Yes. Though even without that file I can see the anime does match in the logs, when it is scanned initially. I just tried this again to verify. Once more upon a change in the directory it was autodetected, the files appeared in plex and started being analyzed. Upon a second scan however the files vanished from the library. Everything was properly chownd and chmodd. To be certain I made the chown and chmod commands recursive with -R; so absolutely everything had the same permissions / ownership.

If you see this appear in your log files, it means you need to perform the Plex Dance to clear the hash. As it says in this line, it does assign the file of Episode 13 to the metadata of episode 12.

@OttoKerner I did do that; as you can see by the date that snippet was from a few weeks ago. I just searched the string ‘hash match’ in some old / already downloaded logs as evidence that this wasn’t a permissions problem; but I did do the plex dance multiple times as advised above. The dance did not help

@zwimer Please disable empty trash after scan

I tried this, it did not change anything. I imagine if it did it would just postpone whatever is causing the disappearance, but even with this disabled the item is immediately removed after the second scan.

That should not be possible. That setting is specifically there for this issue. Plex only removes things when the trash is emptied. Unless your file naming is so far out of standard that plex is combining/splitting the media each scan (again should not be possible if that auto empty is disabled)

@chuckpa thoughts on cloning @zwimer’s file layout and seeing if you can recreate this issue?

With a full listing of all files indexed into Plex, I can recreate the entire structure

To obtain such a list,

  1. If the media is on /nas/media/
  2. find /nas/media -type f -print > some_text_file

When complete, some_text_file will be the listing I need.

Should it be necessary, I can also extract the list of pathnames in the DB and recreate a directory structure from that.

Were I to combine the two, I could then generate a list where pathname != DB pathname.

It’s fairly simple shell scriping to brute-force check it all.
Fortunately my file server is good a brute-force tasks

I’ll pm you these; I can also provide logs (let me know if you want them). For the logs, if you need a time stamp regarding the trash emptying disabled thing, I did it just before my post mentioning that it didn’t work. I did find in the relevant library, anime. The full path to the anime library is just /anime; so if you want to perfectly recreate the file structure just prepend a / to each line.

@ChuckPa How do I PM you? I know with normal users I can click their icon then click message, but that button doesn’t appear when I click your icon like it does other users.

PM sent