diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2026-02-07 08:44:42 +0100 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2026-02-07 09:37:42 +0100 |
| commit | 98d7c8d59fa3180e50ee311dfc53164325210896 (patch) | |
| tree | 3a50217f9796d27c5a150cb84dd64e88c1969102 /Jellyfin.Server.Implementations | |
| parent | 268d88a5fb8f0f71c96ba5abcef250d1f7e049ff (diff) | |
Make sure we deduplicate LinkedChildren
Diffstat (limited to 'Jellyfin.Server.Implementations')
| -rw-r--r-- | Jellyfin.Server.Implementations/Item/BaseItemRepository.cs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs index 20df42583d..3ba6750045 100644 --- a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs +++ b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs @@ -1553,7 +1553,13 @@ public sealed class BaseItemRepository } } - var childIdsToCheck = resolvedChildren.Select(c => c.ChildId).Distinct().ToList(); + // Deduplicate by ChildId, keeping the last occurrence (for playlist ordering) + resolvedChildren = resolvedChildren + .GroupBy(c => c.ChildId) + .Select(g => g.Last()) + .ToList(); + + var childIdsToCheck = resolvedChildren.Select(c => c.ChildId).ToList(); var existingChildIds = childIdsToCheck.Count > 0 ? context.BaseItems .Where(e => childIdsToCheck.Contains(e.Id)) @@ -1646,8 +1652,14 @@ public sealed class BaseItemRepository } } + // Deduplicate by ChildId, keeping the last occurrence + newLinkedChildren = newLinkedChildren + .GroupBy(c => c.ChildId) + .Select(g => g.Last()) + .ToList(); + // Validate that all child items exist - var childIdsToCheck = newLinkedChildren.Select(c => c.ChildId).Distinct().ToList(); + var childIdsToCheck = newLinkedChildren.Select(c => c.ChildId).ToList(); var existingChildIds = childIdsToCheck.Count > 0 ? context.BaseItems .Where(e => childIdsToCheck.Contains(e.Id)) |
