diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2026-02-07 19:01:37 +0100 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2026-02-07 19:01:37 +0100 |
| commit | 2420ece5fe47c3d990641add1648b9c220215a62 (patch) | |
| tree | 1e21e237ac81b944957f376abbaa626228a8b6b7 /MediaBrowser.Controller/Entities/Video.cs | |
| parent | 00dd84035ee39b36da343e0d98d7dc83246c5f89 (diff) | |
Fix version resolution and scan handling
Diffstat (limited to 'MediaBrowser.Controller/Entities/Video.cs')
| -rw-r--r-- | MediaBrowser.Controller/Entities/Video.cs | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 21aa50b49d..e06875b64c 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -457,10 +457,20 @@ namespace MediaBrowser.Controller.Entities { RefreshLinkedAlternateVersions(); - var tasks = LocalAlternateVersions - .Select(i => RefreshMetadataForVersions(options, false, i, cancellationToken)); + if (LocalAlternateVersions.Length > 0) + { + // Check if LinkedChildren are in sync before processing + var existingLinkCount = LibraryManager.GetLocalAlternateVersionIds(this).Count(); + var tasks = LocalAlternateVersions + .Select(i => RefreshMetadataForVersions(options, false, i, cancellationToken)); + + await Task.WhenAll(tasks).ConfigureAwait(false); - await Task.WhenAll(tasks).ConfigureAwait(false); + if (existingLinkCount != LocalAlternateVersions.Length) + { + hasChanges = true; + } + } } } @@ -470,6 +480,15 @@ namespace MediaBrowser.Controller.Entities protected virtual async Task RefreshMetadataForVersions(MetadataRefreshOptions options, bool copyTitleMetadata, string path, CancellationToken cancellationToken) { await RefreshMetadataForOwnedVideo(options, copyTitleMetadata, path, cancellationToken).ConfigureAwait(false); + + // Create LinkedChild entry for this local alternate version + // This ensures the relationship exists in the database even if the alternate version + // was created after the primary video was first saved + var id = LibraryManager.GetNewItemId(path, GetType()); + if (LibraryManager.GetItemById(id) is Video video) + { + LibraryManager.UpsertLinkedChild(Id, video.Id, LinkedChildType.LocalAlternateVersion); + } } private new async Task RefreshMetadataForOwnedVideo(MetadataRefreshOptions options, bool copyTitleMetadata, string path, CancellationToken cancellationToken) @@ -496,7 +515,12 @@ namespace MediaBrowser.Controller.Entities if (LibraryManager.GetItemById(id) is not Video video) { - video = LibraryManager.ResolvePath(FileSystem.GetFileSystemInfo(path)) as Video; + var parentFolder = GetParent() as Folder; + var collectionType = GetParents().OfType<ICollectionFolder>().FirstOrDefault()?.CollectionType; + video = LibraryManager.ResolvePath( + FileSystem.GetFileSystemInfo(path), + parentFolder, + collectionType: collectionType) as Video; newOptions.ForceSave = true; } @@ -512,11 +536,6 @@ namespace MediaBrowser.Controller.Entities } await RefreshMetadataForOwnedItem(video, copyTitleMetadata, newOptions, cancellationToken).ConfigureAwait(false); - - // Create LinkedChild entry for this local alternate version - // This ensures the relationship exists in the database even if the alternate version - // was created after the primary video was first saved - LibraryManager.UpsertLinkedChild(Id, video.Id, LinkedChildType.LocalAlternateVersion); } private void RefreshLinkedAlternateVersions() |
