From aedd2b04a2687adfcc52db96aa3fb7b2ad94fdcc Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Wed, 4 Feb 2026 19:16:55 +0100 Subject: [PATCH] Fix alternative Versions and prevent over fetching --- Jellyfin.Server.Implementations/Item/BaseItemRepository.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs index 415f2b99cd..b154592e6e 100644 --- a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs +++ b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs @@ -983,7 +983,7 @@ public sealed class BaseItemRepository BaseItemKind.Video, BaseItemKind.Movie }; - if (filter.IncludeItemTypes.Length == 0 || filter.IncludeItemTypes.Any(linkedChildTypes.Contains)) + if (filter.IncludeItemTypes.Length > 0 && filter.IncludeItemTypes.Any(linkedChildTypes.Contains)) { dbQuery = dbQuery.Include(e => e.LinkedChildEntities); } @@ -1399,6 +1399,10 @@ public sealed class BaseItemRepository } } + // This is necessary because LocalAlternateVersions resolution queries the database by path, + // and newly imported alternate version items need to exist before we can link them + context.SaveChanges(); + var folderIds = tuples .Where(t => t.Item is Folder) .Select(t => t.Item.Id) @@ -1603,6 +1607,7 @@ public sealed class BaseItemRepository } } + // Phase 2 commit: Save LinkedChildren changes context.SaveChanges(); transaction.Commit(); }