浏览代码

Enable child items to be returned if a musicAlbum

BaronGreenback 4 年之前
父节点
当前提交
48bb338352
共有 2 个文件被更改,包括 27 次插入3 次删除
  1. 22 3
      MediaBrowser.Controller/Entities/Folder.cs
  2. 5 0
      MediaBrowser.Controller/Entities/InternalItemsQuery.cs

+ 22 - 3
MediaBrowser.Controller/Entities/Folder.cs

@@ -939,7 +939,13 @@ namespace MediaBrowser.Controller.Entities
             }
             else
             {
-                items = GetChildren(user, true).Where(filter);
+                // need to pass this param to the children.
+                var childQuery = new InternalItemsQuery
+                {
+                    DisplayAlbumFolders = query.DisplayAlbumFolders
+                };
+
+                items = GetChildren(user, true, childQuery).Where(filter);
             }
 
             return PostFilterAndSort(items, query, true);
@@ -1275,10 +1281,23 @@ namespace MediaBrowser.Controller.Entities
         /// <summary>
         /// Adds the children to list.
         /// </summary>
-        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
         private void AddChildren(User user, bool includeLinkedChildren, Dictionary<Guid, BaseItem> result, bool recursive, InternalItemsQuery query)
         {
-            foreach (var child in GetEligibleChildrenForRecursiveChildren(user))
+            // If Query.AlbumFolders is set, then enforce the format as per the db in that it permits sub-folders in music albums.
+            IEnumerable<BaseItem> children = null;
+            if ((query?.DisplayAlbumFolders ?? false) && (this is MusicAlbum))
+            {
+                children = Children;
+                query = null;
+            }
+
+            // If there are not sub-folders, proceed as normal.
+            if (children == null)
+            {
+                children = GetEligibleChildrenForRecursiveChildren(user);
+            }
+
+            foreach (var child in children)
             {
                 bool? isVisibleToUser = null;
 

+ 5 - 0
MediaBrowser.Controller/Entities/InternalItemsQuery.cs

@@ -265,6 +265,11 @@ namespace MediaBrowser.Controller.Entities
 
         public bool? IsDeadPerson { get; set; }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether album sub-folders should be returned if they exist.
+        /// </summary>
+        public bool? DisplayAlbumFolders { get; set; }
+
         public InternalItemsQuery()
         {
             AlbumArtistIds = Array.Empty<Guid>();