diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2026-08-14 07:39:49 +0200 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2026-08-14 07:39:49 +0200 |
| commit | c77649d21e6bd53a662b217c6431b7d123d656b9 (patch) | |
| tree | 7b8663fdf4719ae1c53d9f8ebd2900a93ef8537d /src/Jellyfin.Database/Jellyfin.Database.Implementations | |
| parent | 7e6709f023bab9421a1219e5a59f34e1b8208147 (diff) | |
Skip alternate version links when resolving link parents
Diffstat (limited to 'src/Jellyfin.Database/Jellyfin.Database.Implementations')
| -rw-r--r-- | src/Jellyfin.Database/Jellyfin.Database.Implementations/DescendantQueryHelper.cs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/Jellyfin.Database/Jellyfin.Database.Implementations/DescendantQueryHelper.cs b/src/Jellyfin.Database/Jellyfin.Database.Implementations/DescendantQueryHelper.cs index 92adc37ccc..1e1c8780e8 100644 --- a/src/Jellyfin.Database/Jellyfin.Database.Implementations/DescendantQueryHelper.cs +++ b/src/Jellyfin.Database/Jellyfin.Database.Implementations/DescendantQueryHelper.cs @@ -177,9 +177,17 @@ public static class DescendantQueryHelper // Resolves the folders whose linked children lead, at any depth, to a matching item. private static List<Guid> ResolveLinkParents(JellyfinDbContext context, IQueryable<Guid> matchingItemIds, IQueryable<Guid> ancestorsOfMatches) { + // An alternate version is a second file for the item that links it, not a child of it, so that + // edge is not walked. It is also the one link a non-folder owns, and there is one per remuxed + // movie: walking it would swell this list from the BoxSet and Playlist count to the item count, + // and the list is bound into every statement the returned queryable is embedded in. + var containerLinks = context.LinkedChildren + .Where(e => e.ChildType != LinkedChildType.LocalAlternateVersion + && e.ChildType != LinkedChildType.LinkedAlternateVersion); + // A link sits above the closure and above another link alike, so the hop repeats until nothing - // new turns up. Only link owners are collected, which bounds it by BoxSets and Playlists. - var resolved = context.LinkedChildren + // new turns up. + var resolved = containerLinks .Where(e => matchingItemIds.Contains(e.ChildId) || ancestorsOfMatches.Contains(e.ChildId)) .Select(e => e.ParentId) .Distinct() @@ -193,11 +201,11 @@ public static class DescendantQueryHelper .WhereOneOrMany(frontier, e => e.ItemId) .Select(e => e.ParentItemId); - var directLinkParents = context.LinkedChildren + var directLinkParents = containerLinks .WhereOneOrMany(frontier, e => e.ChildId) .Select(e => e.ParentId); - var indirectLinkParents = context.LinkedChildren + var indirectLinkParents = containerLinks .Where(e => containingFolders.Contains(e.ChildId)) .Select(e => e.ParentId); |
