From 8e80677bdd6471d04748cfcca41f997f2f48b341 Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Fri, 21 Aug 2026 22:48:47 +0200 Subject: Fix series merging leaking across libraries and under-counting merged children --- .../DescendantQueryHelper.cs | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/Jellyfin.Database/Jellyfin.Database.Implementations') diff --git a/src/Jellyfin.Database/Jellyfin.Database.Implementations/DescendantQueryHelper.cs b/src/Jellyfin.Database/Jellyfin.Database.Implementations/DescendantQueryHelper.cs index bfd0fac34a..909609e35d 100644 --- a/src/Jellyfin.Database/Jellyfin.Database.Implementations/DescendantQueryHelper.cs +++ b/src/Jellyfin.Database/Jellyfin.Database.Implementations/DescendantQueryHelper.cs @@ -39,6 +39,31 @@ public static class DescendantQueryHelper return descendants.AsQueryable(); } + /// + /// Gets all descendant IDs for multiple parent items in a single traversal. + /// Traverses AncestorIds and LinkedChildren, like . + /// + /// Database context. + /// Parent item IDs. + /// Set of all descendant item IDs (excluding the parent IDs themselves). + public static HashSet GetAllDescendantIdsBatch(JellyfinDbContext context, IReadOnlyList parentIds) + { + ArgumentNullException.ThrowIfNull(context); + ArgumentNullException.ThrowIfNull(parentIds); + + if (parentIds.Count == 0) + { + return []; + } + + var seedSet = new HashSet(parentIds); + var descendants = TraverseHierarchyDown(context, seedSet); + + descendants.ExceptWith(seedSet); + + return descendants; + } + /// /// Gets a queryable of all owned descendant IDs for a parent item. /// Traverses only AncestorIds (hierarchical ownership), NOT LinkedChildren (associations). -- cgit v1.2.3