From 970c95959aedb85211e4af2d7dca44ec2614f767 Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Sun, 23 Jun 2024 11:40:47 -0400 Subject: [PATCH] Backport pull request #12039 from jellyfin/release-10.9.z Fix local episode image thumb recognition Original-merge: d813f83b4a79974326f45d5de03dd7ad72cbd4a8 Merged-by: Bond-009 Backported-by: Joshua M. Boniface --- .../Images/EpisodeLocalImageProvider.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs index 6a5e3bf04a..f00d508bbe 100644 --- a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs +++ b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs @@ -40,13 +40,12 @@ namespace MediaBrowser.LocalMetadata.Images var parentPathFiles = directoryService.GetFiles(parentPath); var nameWithoutExtension = Path.GetFileNameWithoutExtension(item.Path.AsSpan()).ToString(); - var thumbName = string.Concat(nameWithoutExtension, "-thumb"); - var images = GetImageFilesFromFolder(thumbName, parentPathFiles); + var images = GetImageFilesFromFolder(nameWithoutExtension, parentPathFiles); - var metadataSubPath = directoryService.GetDirectories(parentPath).Where(d => d.Name.EndsWith("metadata", StringComparison.OrdinalIgnoreCase)).ToList(); - foreach (var path in metadataSubPath) + var metadataSubDir = directoryService.GetDirectories(parentPath).FirstOrDefault(d => d.Name.Equals("metadata", StringComparison.Ordinal)); + if (metadataSubDir is not null) { - var files = directoryService.GetFiles(path.FullName); + var files = directoryService.GetFiles(metadataSubDir.FullName); images.AddRange(GetImageFilesFromFolder(nameWithoutExtension, files)); } @@ -55,9 +54,8 @@ namespace MediaBrowser.LocalMetadata.Images private List GetImageFilesFromFolder(ReadOnlySpan filenameWithoutExtension, List filePaths) { - var thumbName = string.Concat(filenameWithoutExtension, "-thumb"); - var list = new List(1); + var thumbName = string.Concat(filenameWithoutExtension, "-thumb"); foreach (var i in filePaths) {