diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2026-02-23 09:05:43 +0100 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2026-02-23 09:05:43 +0100 |
| commit | ea0641b659fd6a3290453d3d70d5d82e63eb397d (patch) | |
| tree | 811726363d8a754b9219a970fff2c0056e89cbdb | |
| parent | 6ce5f9dfd5d9a27cf70366f35948b2f02e941389 (diff) | |
Fix version promotion
| -rw-r--r-- | Emby.Server.Implementations/Library/LibraryManager.cs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 60ac15ca97..88d29b73c9 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -427,6 +427,17 @@ namespace Emby.Server.Implementations.Library // Promote the first alternate version to be the new primary var newPrimary = alternateVersions[0]; newPrimary.SetPrimaryVersionId(null); + newPrimary.OwnerId = Guid.Empty; + + // Transfer alternate version arrays from old primary to new primary + // so UpdateToRepositoryAsync creates correct LinkedChildren entries + newPrimary.LocalAlternateVersions = video.LocalAlternateVersions + .Where(p => !string.Equals(p, newPrimary.Path, StringComparison.OrdinalIgnoreCase)) + .ToArray(); + newPrimary.LinkedAlternateVersions = video.LinkedAlternateVersions + .Where(lc => !lc.ItemId.HasValue || !lc.ItemId.Value.Equals(newPrimary.Id)) + .ToArray(); + newPrimary.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, CancellationToken.None).GetAwaiter().GetResult(); // Re-route playlist/collection references from deleted primary to new primary @@ -436,6 +447,7 @@ namespace Emby.Server.Implementations.Library foreach (var alternate in alternateVersions.Skip(1)) { alternate.SetPrimaryVersionId(newPrimary.Id); + alternate.OwnerId = newPrimary.Id; alternate.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, CancellationToken.None).GetAwaiter().GetResult(); } } |
