mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-03 23:36:38 +01:00
Optimize accessibility checks
This commit is contained in:
@@ -1350,8 +1350,27 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
if (itemCollectionFolders.Count > 0)
|
||||
{
|
||||
var userCollectionFolders = LibraryManager.GetUserRootFolder().GetChildren(user, true).Select(i => i.Id).ToList();
|
||||
if (!itemCollectionFolders.Any(userCollectionFolders.Contains))
|
||||
var blockedMediaFolders = user.GetPreferenceValues<Guid>(PreferenceKind.BlockedMediaFolders);
|
||||
IEnumerable<Guid> userCollectionFolderIds;
|
||||
if (blockedMediaFolders.Length > 0)
|
||||
{
|
||||
// User has blocked folders - get all library folders and exclude blocked ones
|
||||
userCollectionFolderIds = LibraryManager.GetUserRootFolder().Children
|
||||
.Select(i => i.Id)
|
||||
.Where(id => !blockedMediaFolders.Contains(id));
|
||||
}
|
||||
else if (user.HasPermission(PermissionKind.EnableAllFolders))
|
||||
{
|
||||
// User can access all folders - no need to filter
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// User has specific enabled folders
|
||||
userCollectionFolderIds = user.GetPreferenceValues<Guid>(PreferenceKind.EnabledFolders);
|
||||
}
|
||||
|
||||
if (!itemCollectionFolders.Any(userCollectionFolderIds.Contains))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1699,8 +1699,11 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
if (SupportsPlayedStatus || (itemDto is not null && fields.ContainsField(ItemFields.RecursiveItemCount)))
|
||||
{
|
||||
// Create a minimal query with just the user - skip ConfigureUserAccess to avoid
|
||||
// expensive GetUserViews calls. Since we're counting descendants of a specific
|
||||
// item (this folder) that the user already has access to, TopParentIds filtering
|
||||
// is redundant. The parental rating filter is applied via query.User.
|
||||
var query = new InternalItemsQuery(user);
|
||||
LibraryManager.ConfigureUserAccess(query, user);
|
||||
|
||||
int playedCount;
|
||||
int totalCount;
|
||||
|
||||
Reference in New Issue
Block a user