diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2026-02-25 21:03:46 +0100 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2026-02-25 21:03:46 +0100 |
| commit | 2d0d497961a7ca990384bd180f381824d5591cb8 (patch) | |
| tree | 3648fbc3612af0855b3a7328649b95045a87900c /Jellyfin.Server.Implementations/Item/BaseItemRepository.cs | |
| parent | 4bd9dbe9108c55bc788e35346498f710187d401d (diff) | |
Update saved metadata on primary change
Diffstat (limited to 'Jellyfin.Server.Implementations/Item/BaseItemRepository.cs')
| -rw-r--r-- | Jellyfin.Server.Implementations/Item/BaseItemRepository.cs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs index dea4e04108..6e80d38d7d 100644 --- a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs +++ b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs @@ -4439,10 +4439,22 @@ public sealed class BaseItemRepository } /// <inheritdoc/> - public int RerouteLinkedChildren(Guid fromChildId, Guid toChildId) + public IReadOnlyList<Guid> RerouteLinkedChildren(Guid fromChildId, Guid toChildId) { using var context = _dbProvider.CreateDbContext(); + // Collect all affected parent IDs before modifying + var affectedParentIds = context.LinkedChildren + .Where(lc => lc.ChildId == fromChildId && lc.ChildType == DbLinkedChildType.Manual) + .Select(lc => lc.ParentId) + .Distinct() + .ToList(); + + if (affectedParentIds.Count == 0) + { + return affectedParentIds; + } + // Get parents that already reference toChildId (to avoid duplicates) var parentsWithTarget = context.LinkedChildren .Where(lc => lc.ChildId == toChildId && lc.ChildType == DbLinkedChildType.Manual) @@ -4450,7 +4462,7 @@ public sealed class BaseItemRepository .ToHashSet(); // Update references that won't create duplicates - var updated = context.LinkedChildren + context.LinkedChildren .Where(lc => lc.ChildId == fromChildId && lc.ChildType == DbLinkedChildType.Manual && !parentsWithTarget.Contains(lc.ParentId)) @@ -4463,7 +4475,7 @@ public sealed class BaseItemRepository && parentsWithTarget.Contains(lc.ParentId)) .ExecuteDelete(); - return updated; + return affectedParentIds; } /// <inheritdoc/> |
