Are metadata files deleted when an episode is replaced with higher quality?

I’m trying to track down an issue with missing metadata from Emby. When Sonarr downloads a higher quality file, does it delete the existing metadata files for that episode? I don’t have any metadata settings enabled in Sonarr, but whenever an episode is replaced, the metadata .xml for that episode is missing.

If Sonarr has detected it exists and it is a known format then yes it is deleted.

1 Like

Thanks for the answer. Is there any way to prevent the deletion?

Not at the moment. Can you elaborate on why this is a problem with Emby?

The short answer is that if I don’t use the quality in the file renaming options in Sonarr, this is preventing Emby from automatically generating new metadata files.

Long answer: In order to prevent Emby from seeing higher quality replacements as new files, I set the file renaming options so that the quality is not part of the file name. In that case when episodes are replaced, the new file will have the same file name as the original.

What I have been observing is that when an episode is replaced, the episode thumbnail <episode_name>.jpg and metadata files <episode_name>.xml are deleted. I have real time monitoring in Emby enabled which means that Emby sees the changed files and tries to recreate the thumbnail and metadata files. The thumbnail is generated properly, but the metadata file is missing after Emby completes the process. It seems that either Sonarr is preventing the new file from being generated with some sort of file lock. Since Emby thinks that it was successful in generating the files, it never tries to create the metadata files again. The only way to fix this is a manual refresh in Emby. If I could prevent Sonarr from removing the original file this would prevent this issue from occurring.

As a workaround I have changed the file renaming options to use the file quality in the name. In this case, Emby just generates the new metadata files the new metadata files will have the quality in the name as well. However, this causes some of the other clients such as the Emby for Kodi client to believe that I have duplicate copies of the same episode.

On Windows a lock would prevent Emby from creating it and on non-Windows there really isn’t a concept of locks so it shouldn’t prevent Emby from re-creating it.

From a solution standpoint I’m not sure that we want to implement an option to prevent the files from being deleted.

//cc @Taloth

Either way thanks for the information. It helps me understand the process and my options.