Showing merged file count despite there only being 1 file on disk

Server Version#: 1.22.1.4200
Player Version#: All tested (Mac, Android, AppleTV)

I’m running Sonarr/Radarr with Plex. When a media file is first downloaded, Plex imports it, everything is good. When *arr pulls down a better copy, it deletes the original, however Plex shows the cumulative count as merged files, despite there only being one copy on disk.

Restarting player, server, and rescanning library files does not clear up this duplication.

do you have Empty trash automatically after every scan enabled ?

Under, Settings → Library

I do, and the scans are set to hourly. The files are deleted by *arr and shouldn’t be visible to Plex after deletion. They are either wiped from disk or go to a hidden dir on the NAS, far away from the Plex library dirs.

@OttoKerner, you seem to be the master here, any thoughts?

Is this this only avenue for reporting bugs?

It is. I passed this along to our server team. @sa2000 is really good too for helping identify and advocate for server issues.

Good to know, thank you

@drewwats Do you still have the problem?

This screenshot shows two files with the same name for S03E10 - but the explorer view stops short and does not show files for S03E10

I had an issue before where two file names appeared to be identical - which of course should never happen - it turned out to be some unicode character i picked up when copying a title from a web page

Screenshot of what I had which was obvious once pasting the name into Notepad++ text file and viewing in HexEdit

This is just a guess that you may have some invisible extended characters making the two files appear to be different in name

@sa2000, thanks for the reply,

I’ll use another example to clarify, Zoey’s Extraordinary Playlist/Season 02/Zoey’s Extraordinary Playlist – S02E08

Here is Plex XML file under “Get Info”. You can see this filename (identical) appears twice, each with separate Media id:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<MediaContainer size="1" allowSync="1" identifier="com.plexapp.plugins.library" librarySectionID="7" librarySectionTitle="Requests" librarySectionUUID="431013a7-39d3-47c7-b7c7-c6bbde5782a1" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1617650286">
<Video ratingKey="25958" key="/library/metadata/25958" parentRatingKey="24733" grandparentRatingKey="24732" guid="com.plexapp.agents.thetvdb://363815/2/8?lang=en" parentGuid="com.plexapp.agents.thetvdb://363815/2?lang=en" grandparentGuid="com.plexapp.agents.thetvdb://363815?lang=en" type="episode" title="Zoey's Extraordinary Birthday" grandparentKey="/library/metadata/24732" parentKey="/library/metadata/24733" librarySectionTitle="Requests" librarySectionID="7" librarySectionKey="/library/sections/7" grandparentTitle="Zoey's Extraordinary Playlist" parentTitle="Season 2" contentRating="TV-14" summary="It's Zoey's 30th birthday, but before she can celebrate properly she must confront her unresolved feelings for the men in her life." index="8" parentIndex="2" year="2021" thumb="/library/metadata/25958/thumb/1617589651" art="/library/metadata/24732/art/1617589651" parentThumb="/library/metadata/24733/thumb/1616986171" grandparentThumb="/library/metadata/24732/thumb/1617589651" grandparentArt="/library/metadata/24732/art/1617589651" duration="2581653" originallyAvailableAt="2021-04-04" addedAt="1617589611" updatedAt="1617589651">
<Media id="46836" duration="2581653" bitrate="4838" width="1920" height="1080" aspectRatio="1.78" audioChannels="6" audioCodec="aac" videoCodec="h264" videoResolution="1080" container="mkv" videoFrameRate="24p" audioProfile="lc" videoProfile="high">
<Part accessible="1" exists="1" id="57253" key="/library/parts/57253/1617589544/file.mkv" duration="2581653" file="/requests/Zoey's Extraordinary Playlist/Season 02/Zoey's Extraordinary Playlist – S02E08 (WEBDL-1080p h264 8bit AAC 5.1).mkv" size="1562036332" audioProfile="lc" container="mkv" deepAnalysisVersion="4" indexes="sd" requiredBandwidths="5849,5655,5159,5159,5159,5159,5159,5159" videoProfile="high">
<Stream id="205762" streamType="1" default="1" codec="h264" index="0" bitrate="4392" bitDepth="8" chromaLocation="left" chromaSubsampling="4:2:0" codedHeight="1088" codedWidth="1920" colorPrimaries="bt709" colorRange="tv" colorSpace="bt709" colorTrc="bt709" frameRate="23.976" hasScalingMatrix="0" height="1080" level="40" profile="high" refFrames="4" requiredBandwidths="5404,5209,4718,4718,4718,4718,4718,4718" scanType="progressive" width="1920" displayTitle="1080p (H.264)" extendedDisplayTitle="1080p (H.264)"> </Stream>
<Stream id="205763" streamType="2" selected="1" default="1" codec="aac" index="1" channels="6" bitrate="445" language="English" languageCode="eng" audioChannelLayout="5.1" profile="lc" requiredBandwidths="445,445,445,445,445,445,445,445" samplingRate="48000" displayTitle="English (AAC 5.1)" extendedDisplayTitle="English (AAC 5.1)"> </Stream>
<Stream id="205764" streamType="3" selected="1" codec="srt" index="2" bitrate="0" language="English" languageCode="eng" requiredBandwidths="1,1,1,1,1,1,1,1" displayTitle="English (SRT)" extendedDisplayTitle="English (SRT)"> </Stream>
</Part>
</Media>
<Media id="46837" duration="2581653" bitrate="4838" width="1920" height="1080" aspectRatio="1.78" audioChannels="6" audioCodec="aac" videoCodec="h264" videoResolution="1080" container="mkv" videoFrameRate="24p" audioProfile="lc" videoProfile="high">
<Part accessible="1" exists="1" id="57254" key="/library/parts/57254/1617589544/file.mkv" duration="2581653" file="/requests/Zoey's Extraordinary Playlist/Season 02/Zoey's Extraordinary Playlist – S02E08 (WEBDL-1080p h264 8bit AAC 5.1).mkv" size="1562036332" audioProfile="lc" container="mkv" deepAnalysisVersion="4" indexes="sd" requiredBandwidths="5849,5655,5159,5159,5159,5159,5159,5159" videoProfile="high">
<Stream id="205759" streamType="1" default="1" codec="h264" index="0" bitrate="4392" bitDepth="8" chromaLocation="left" chromaSubsampling="4:2:0" codedHeight="1088" codedWidth="1920" colorPrimaries="bt709" colorRange="tv" colorSpace="bt709" colorTrc="bt709" frameRate="23.976" hasScalingMatrix="0" height="1080" level="40" profile="high" refFrames="4" requiredBandwidths="5404,5209,4718,4718,4718,4718,4718,4718" scanType="progressive" width="1920" displayTitle="1080p (H.264)" extendedDisplayTitle="1080p (H.264)"> </Stream>
<Stream id="205760" streamType="2" selected="1" default="1" codec="aac" index="1" channels="6" bitrate="445" language="English" languageCode="eng" audioChannelLayout="5.1" profile="lc" requiredBandwidths="445,445,445,445,445,445,445,445" samplingRate="48000" displayTitle="English (AAC 5.1)" extendedDisplayTitle="English (AAC 5.1)"> </Stream>
<Stream id="205761" streamType="3" selected="1" codec="srt" index="2" bitrate="0" language="English" languageCode="eng" requiredBandwidths="1,1,1,1,1,1,1,1" displayTitle="English (SRT)" extendedDisplayTitle="English (SRT)"> </Stream>
</Part>
</Media>
<Extras size="0"> </Extras>
<Related> </Related>
</Video>
</MediaContainer>

And here is the directory listing for this Series/Season, notice there is only one copy:

Docker# ll /Requests/Zoey\'s\ Extraordinary\ Playlist/Season\ 02/
total 16G
drwxrwxrwx+ 1 root root 1.4K Apr  5 05:07  @eaDir
drwxrwxr-x  1 root root 2.2K Apr  4 21:26  .
-rw-rw-r--  1 root root 1.5G Apr  4 21:25 'Zoey'\''s Extraordinary Playlist – S02E08 (WEBDL-1080p h264 8bit AAC 5.1).mkv'
-rw-rw-r--  1 root root 2.9G Mar 30 03:56 'Zoey'\''s Extraordinary Playlist – S02E07 (WEBDL-1080p x264 8bit EAC3 5.1).mkv'
-rw-rw-r--  1 root root  55K Feb 15 12:34 'Zoey'\''s Extraordinary Playlist – S02E06 (WEBDL-1080p h264 8bit AAC 5.1).en.srt'
-rw-rw-r--  1 root root 1.3G Feb  9 21:12 'Zoey'\''s Extraordinary Playlist – S02E06 (WEBDL-1080p h264 8bit AAC 5.1).mkv'
-rw-rw-r--  1 root root  58K Feb  6 21:23 'Zoey'\''s Extraordinary Playlist – S02E05 (WEBDL-1080p h264 8bit AAC 5.1).en.srt'
-rw-rw-r--  1 root root 1.4G Feb  2 21:02 'Zoey'\''s Extraordinary Playlist – S02E05 (WEBDL-1080p h264 8bit AAC 5.1).mkv'
-rw-rw-r--  1 root root  52K Feb  1 19:16 'Zoey'\''s Extraordinary Playlist – S02E04 (WEBDL-1080p x264 8bit EAC3 5.1).en.srt'
-rw-rw-r--  1 root root 3.1G Jan 27 06:45 'Zoey'\''s Extraordinary Playlist – S02E04 (WEBDL-1080p x264 8bit EAC3 5.1).mkv'
-rw-rw-r--  1 root root  54K Jan 22 19:27 'Zoey'\''s Extraordinary Playlist – S02E03 (WEBDL-1080p h264 8bit AAC 5.1).en.srt'
-rw-rw-r--  1 root root  53K Jan 20 11:47 'Zoey'\''s Extraordinary Playlist – S02E02 (WEBDL-1080p h264 8bit AAC 5.1).en.srt'
-rw-rw-r--  1 root root 1.2G Jan 19 22:11 'Zoey'\''s Extraordinary Playlist – S02E03 (WEBDL-1080p h264 8bit AAC 5.1).mkv'
-rw-rw-r--  1 root root 1.4G Jan 12 23:34 'Zoey'\''s Extraordinary Playlist – S02E02 (WEBDL-1080p h264 8bit AAC 5.1).mkv'
-rw-rw-r--  1 root root  50K Jan 12 00:30 'Zoey'\''s Extraordinary Playlist – S02E01 (WEBDL-1080p x264 8bit EAC3 5.1).en.srt'
drwxrwxr-x  1 root root   36 Jan  8 03:56  ..
-rw-rw-r--  1 root root 3.0G Jan  7 23:23 'Zoey'\''s Extraordinary Playlist – S02E01 (WEBDL-1080p x264 8bit EAC3 5.1).mkv'
root@Synology:/Docker#

Thank you

Does the problem still arise if the filenames had the normal “-” character rather than EN DASH which is Hex E2 80 93

The extended dash is here Playlist – S02E08

I use the same naming convention everywhere. I could theoretically rename my entire library, but I would argue that the issue does not occur with a vast majority of files, despite using the en dash.

Worth note, I pulled this naming convention directly from Plex support page which is using the en dash but notes that the separator type does not matter.
Naming and Organizing Your TV Show Files | Plex Support

Though my original hypothesis was that this had to do with files being upgraded by Sonarr, the most recent example was never upgraded. This is the only copy that has existed despite Plex reporting faux duplication.

Thanks - how are the files added to the library ?

Initially I presume the media info just shows one filename in the media info

Later on it becomes two. Could you get me server debug logs zip covering the time between it being just 1 file and then becoming two? Taking media info xml at each of the two stages

Do you just copy the new updated file into the directory to overwrite the existing one ? and Plex Media Server is somehow not detecting it is in the library and adds it again - would like to see logs

Please make sure debug logging enabled before starting the tests and have a server restart to get fresh logs created

Thanks

Files are added to the library by Sonarr. It moves them there once pulled and Plex triggers a scan.

I’m not sure if it ever shows only one copy of the file, I haven’t been able to catch it in that specific moment yet.

When the file does get upgraded, it will have a different filename due to the nature of it being an upgraded copy. (This different filename might also be an indicator the issue has nothing to do with the automatic upgrades.) Sonarr will move the new file to the target directory, then delete the inferior copy.

As I mentioned, this might not have anything to do with file upgrade/replacement since it appears this file was only pulled down once Zoey’s Extraordinary Playlist – S02E08

I have enabled debug logging but will have to wait for the issue to recur organically before we have solid data.

FWIW, I have been a Plex server user and Plex Pass owner since the beginning and this issue is new to me.

Thanks - will wait for next occurrence and hopefully you can catch it also between the time the file is replaced

So what are the operating system commands executed to replace the existing file?

Is it one file with different name added and the existing file deleted ? and then scan performed with empty trash option enabled by default?

I will be waiting for a new episode to show the duplication, whether or not the file was ever upgraded or replaced. I want to distance ourselves from the idea that the issue is related to upgrade/replacement because it now appears it is not. I would also like to note, that regardless of the cause, the symptom should clear up after each library scan, but it does not.

So what are the operating system commands executed to replace the existing file?

I did some searching but was unable to find the commands or exact steps Sonarr uses to do this.

Is it one file with different name added and the existing file deleted ? and then scan performed with empty trash option enabled by default?

I believe this to be correct.

@sa2000 - Most recent occurrence, should be captured in the logs I PM’d you.



Sonarr history detailing this particular file was upgraded

Thanks for the new logs and database - unfortunately debug logging was disabled - please enable it, restart the server to get fresh logs set created and wait for next occurrence

Debug Logging was disabled at Apr 08, 2021 08:25
Logs captured at Apr 12, 2021 10:56
I will see if the logs cover any of the earlier occurrences

The logs do cover the time Kung Fu S01E01 was added and updated

I have referred the logs from the 8th April and the above details to the Plex Media Server team. In this case the file was initally

Kung Fu (2021) – S01E01 (WEBDL-1080p h264 8bit AAC 2.0).mkv

and later

Kung Fu (2021) – S01E01 (WEBDL-1080p x264 8bit EAC3 5.1).mkv

The database shows two entries for the file - with same filename

Evidence of the issue arising when there are no updates by Sonarr would be good to have - i.e. just the initial addition of the file

Also - the TV scanner has been changed and will be coming out of beta - see [BETA] New Plex TV Series Scanner - Plex Media Server / Metadata & Adding Files - Plex Forum
It would be good to know if the issue still arises with the new in-line scanner - if you do upgrade the library to the new scanner - would need fresh debug logs and copy of the database if the issue persists