mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-10-26 16:45:09 +00:00
Backport pull request #18039 from jellyfin/release-12.z
Stop resolving items with every field where only stored columns are read
Original-merge: 408e5e01b1
Merged-by: crobibero <cody@robibe.ro>
Backported-by: Cody Robibero <cody@robibe.ro>
This commit is contained in:
1 parent
8cd2293ff9
commit
2151b992f9
7 files changed
+76
-36
No files matched your search
@@ -9,6 +9,7 @@ using Jellyfin.Database.Implementations.Entities;
|
||||
using Jellyfin.Extensions;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.Collections;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Library;
|
||||
@@ -235,7 +236,7 @@ namespace Emby.Server.Implementations.Collections
|
||||
|
||||
List<BaseItem>? itemList = null;
|
||||
|
||||
var linkedChildrenList = collection.GetLinkedChildren();
|
||||
var linkedChildrenList = collection.GetLinkedChildren(DtoOptions.StoredColumnsOnly);
|
||||
var currentLinkedChildrenIds = linkedChildrenList.Select(i => i.Id).ToList();
|
||||
|
||||
foreach (var id in ids)
|
||||
|
||||
@@ -60,26 +60,10 @@ namespace Emby.Server.Implementations.Library
|
||||
var folderViewType = collectionFolder?.CollectionType;
|
||||
|
||||
// Playlist and BoxSet libraries require special handling because the folder only references linked items
|
||||
if (folderViewType == CollectionType.boxsets)
|
||||
if ((folderViewType == CollectionType.playlists || folderViewType == CollectionType.boxsets)
|
||||
&& !HasVisibleChild(folder, user))
|
||||
{
|
||||
// Only the existence of one visible box set matters here, so probe the children
|
||||
// lazily and stop at the first hit.
|
||||
if (!folder.Children.Any(item => item.IsVisible(user)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (folderViewType == CollectionType.playlists)
|
||||
{
|
||||
var items = folder.GetItemList(new InternalItemsQuery(user)
|
||||
{
|
||||
ParentId = folder.ParentId
|
||||
});
|
||||
|
||||
if (!items.Any(item => item.IsVisible(user)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (UserView.IsUserSpecific(folder))
|
||||
@@ -168,6 +152,32 @@ namespace Emby.Server.Implementations.Library
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private bool HasVisibleChild(Folder folder, User user)
|
||||
{
|
||||
// Folder.Children answers this too, but a collection folder delegates it to its physical
|
||||
// folders, which resolve and then hold on to every child with every field.
|
||||
var parentIds = folder is CollectionFolder collectionFolder && collectionFolder.PhysicalFolderIds.Length > 0
|
||||
? collectionFolder.PhysicalFolderIds
|
||||
: [folder.Id];
|
||||
|
||||
foreach (var parentId in parentIds)
|
||||
{
|
||||
var items = _libraryManager.GetItemList(new InternalItemsQuery(user)
|
||||
{
|
||||
ParentId = parentId,
|
||||
GroupByPresentationUniqueKey = false,
|
||||
DtoOptions = DtoOptions.StoredColumnsOnly
|
||||
});
|
||||
|
||||
if (items.Any(item => item.IsVisible(user)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public UserView GetUserSubViewWithName(string name, Guid parentId, CollectionType? type, string sortName)
|
||||
{
|
||||
var uniqueId = parentId + "subview" + type;
|
||||
|
||||
@@ -371,7 +371,7 @@ namespace Emby.Server.Implementations.Playlists
|
||||
if (extension.Equals(".wpl", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var playlist = new WplPlaylist();
|
||||
foreach (var child in item.GetLinkedChildren())
|
||||
foreach (var child in item.GetLinkedChildren(DtoOptions.StoredColumnsOnly))
|
||||
{
|
||||
var entry = new WplPlaylistEntry()
|
||||
{
|
||||
@@ -404,7 +404,7 @@ namespace Emby.Server.Implementations.Playlists
|
||||
else if (extension.Equals(".zpl", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var playlist = new ZplPlaylist();
|
||||
foreach (var child in item.GetLinkedChildren())
|
||||
foreach (var child in item.GetLinkedChildren(DtoOptions.StoredColumnsOnly))
|
||||
{
|
||||
var entry = new ZplPlaylistEntry()
|
||||
{
|
||||
@@ -440,7 +440,7 @@ namespace Emby.Server.Implementations.Playlists
|
||||
{
|
||||
IsExtended = true
|
||||
};
|
||||
foreach (var child in item.GetLinkedChildren())
|
||||
foreach (var child in item.GetLinkedChildren(DtoOptions.StoredColumnsOnly))
|
||||
{
|
||||
var entry = new M3uPlaylistEntry()
|
||||
{
|
||||
@@ -472,7 +472,7 @@ namespace Emby.Server.Implementations.Playlists
|
||||
IsExtended = true
|
||||
};
|
||||
|
||||
foreach (var child in item.GetLinkedChildren())
|
||||
foreach (var child in item.GetLinkedChildren(DtoOptions.StoredColumnsOnly))
|
||||
{
|
||||
var entry = new M3uPlaylistEntry()
|
||||
{
|
||||
@@ -500,7 +500,7 @@ namespace Emby.Server.Implementations.Playlists
|
||||
else if (extension.Equals(".pls", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var playlist = new PlsPlaylist();
|
||||
foreach (var child in item.GetLinkedChildren())
|
||||
foreach (var child in item.GetLinkedChildren(DtoOptions.StoredColumnsOnly))
|
||||
{
|
||||
var entry = new PlsPlaylistEntry()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user