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 /Emby.Server.Implementations/Library/LibraryManager.cs | |
| parent | 00dd84035ee39b36da343e0d98d7dc83246c5f89 (diff) | |
Fix version resolution and scan handling
Diffstat (limited to 'Emby.Server.Implementations/Library/LibraryManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/Library/LibraryManager.cs | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 29eda7d8b1..6bb5f87d03 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -407,7 +407,8 @@ namespace Emby.Server.Implementations.Library } // If deleting a primary version video, clear PrimaryVersionId from alternate versions - if (item is Video video && string.IsNullOrEmpty(video.PrimaryVersionId)) + // OwnerId check: items with OwnerId set are alternate versions or extras, not primaries + if (item is Video video && string.IsNullOrEmpty(video.PrimaryVersionId) && video.OwnerId.IsEmpty()) { var alternateVersions = GetLocalAlternateVersionIds(video) .Concat(GetLinkedAlternateVersions(video).Select(v => v.Id)) @@ -700,8 +701,8 @@ namespace Emby.Server.Implementations.Library return key.GetMD5(); } - public BaseItem? ResolvePath(FileSystemMetadata fileInfo, Folder? parent = null, IDirectoryService? directoryService = null) - => ResolvePath(fileInfo, directoryService ?? new DirectoryService(_fileSystem), null, parent); + public BaseItem? ResolvePath(FileSystemMetadata fileInfo, Folder? parent = null, IDirectoryService? directoryService = null, CollectionType? collectionType = null) + => ResolvePath(fileInfo, directoryService ?? new DirectoryService(_fileSystem), null, parent, collectionType); private BaseItem? ResolvePath( FileSystemMetadata fileInfo, @@ -2105,6 +2106,8 @@ namespace Emby.Server.Implementations.Library // Resolve and add any local alternate version items that don't exist yet // This ensures they exist in the database when LinkedChildren are processed var allItems = new List<BaseItem>(items); + var parentFolder = parent as Folder; + var parentCollectionType = parent is not null ? GetTopFolderContentType(parent) : null; foreach (var item in items) { if (item is Video video && video.LocalAlternateVersions.Length > 0) @@ -2122,7 +2125,14 @@ namespace Emby.Server.Implementations.Library if (GetItemById(altId) is null && !allItems.Any(i => i.Id.Equals(altId))) { // Alternate version doesn't exist, resolve and create it - var altVideo = ResolvePath(_fileSystem.GetFileSystemInfo(path)) as Video; + // Pass parent and collectionType so the resolver creates the correct type + // (e.g. Movie instead of generic Video) + var altVideo = ResolvePath( + _fileSystem.GetFileSystemInfo(path), + new DirectoryService(_fileSystem), + null, + parentFolder, + parentCollectionType) as Video; if (altVideo is not null) { altVideo.OwnerId = video.Id; @@ -2304,6 +2314,8 @@ namespace Emby.Server.Implementations.Library // Resolve and add any local alternate version items that don't exist yet // This ensures they exist in the database when LinkedChildren are processed var allItems = new List<BaseItem>(items); + var parentFolder = parent as Folder; + var parentCollectionType = GetTopFolderContentType(parent); foreach (var item in items) { if (item is Video video && video.LocalAlternateVersions.Length > 0) @@ -2321,7 +2333,14 @@ namespace Emby.Server.Implementations.Library if (GetItemById(altId) is null && !allItems.Any(i => i.Id.Equals(altId))) { // Alternate version doesn't exist, resolve and create it - var altVideo = ResolvePath(_fileSystem.GetFileSystemInfo(path)) as Video; + // Pass parent and collectionType so the resolver creates the correct type + // (e.g. Movie instead of generic Video) + var altVideo = ResolvePath( + _fileSystem.GetFileSystemInfo(path), + new DirectoryService(_fileSystem), + null, + parentFolder, + parentCollectionType) as Video; if (altVideo is not null) { altVideo.OwnerId = video.Id; |
