|
@@ -4,6 +4,7 @@
|
|
|
|
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
+using System.Collections.Immutable;
|
|
using System.IO;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Security;
|
|
using System.Security;
|
|
@@ -11,6 +12,7 @@ using System.Text.Json.Serialization;
|
|
using System.Threading;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks.Dataflow;
|
|
using System.Threading.Tasks.Dataflow;
|
|
|
|
+using J2N.Collections.Generic.Extensions;
|
|
using Jellyfin.Data.Entities;
|
|
using Jellyfin.Data.Entities;
|
|
using Jellyfin.Data.Enums;
|
|
using Jellyfin.Data.Enums;
|
|
using Jellyfin.Extensions;
|
|
using Jellyfin.Extensions;
|
|
@@ -247,7 +249,7 @@ namespace MediaBrowser.Controller.Entities
|
|
/// We want this synchronous.
|
|
/// We want this synchronous.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns>Returns children.</returns>
|
|
/// <returns>Returns children.</returns>
|
|
- protected virtual List<BaseItem> LoadChildren()
|
|
|
|
|
|
+ protected virtual IReadOnlyList<BaseItem> LoadChildren()
|
|
{
|
|
{
|
|
// logger.LogDebug("Loading children from {0} {1} {2}", GetType().Name, Id, Path);
|
|
// logger.LogDebug("Loading children from {0} {1} {2}", GetType().Name, Id, Path);
|
|
// just load our children from the repo - the library will be validated and maintained in other processes
|
|
// just load our children from the repo - the library will be validated and maintained in other processes
|
|
@@ -659,7 +661,7 @@ namespace MediaBrowser.Controller.Entities
|
|
/// Get our children from the repo - stubbed for now.
|
|
/// Get our children from the repo - stubbed for now.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns>IEnumerable{BaseItem}.</returns>
|
|
/// <returns>IEnumerable{BaseItem}.</returns>
|
|
- protected List<BaseItem> GetCachedChildren()
|
|
|
|
|
|
+ protected IReadOnlyList<BaseItem> GetCachedChildren()
|
|
{
|
|
{
|
|
return ItemRepository.GetItemList(new InternalItemsQuery
|
|
return ItemRepository.GetItemList(new InternalItemsQuery
|
|
{
|
|
{
|
|
@@ -1283,14 +1285,14 @@ namespace MediaBrowser.Controller.Entities
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- public List<BaseItem> GetChildren(User user, bool includeLinkedChildren)
|
|
|
|
|
|
+ public IReadOnlyList<BaseItem> GetChildren(User user, bool includeLinkedChildren)
|
|
{
|
|
{
|
|
ArgumentNullException.ThrowIfNull(user);
|
|
ArgumentNullException.ThrowIfNull(user);
|
|
|
|
|
|
return GetChildren(user, includeLinkedChildren, new InternalItemsQuery(user));
|
|
return GetChildren(user, includeLinkedChildren, new InternalItemsQuery(user));
|
|
}
|
|
}
|
|
|
|
|
|
- public virtual List<BaseItem> GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query)
|
|
|
|
|
|
+ public virtual IReadOnlyList<BaseItem> GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query)
|
|
{
|
|
{
|
|
ArgumentNullException.ThrowIfNull(user);
|
|
ArgumentNullException.ThrowIfNull(user);
|
|
|
|
|
|
@@ -1304,7 +1306,7 @@ namespace MediaBrowser.Controller.Entities
|
|
|
|
|
|
AddChildren(user, includeLinkedChildren, result, false, query);
|
|
AddChildren(user, includeLinkedChildren, result, false, query);
|
|
|
|
|
|
- return result.Values.ToList();
|
|
|
|
|
|
+ return result.Values.ToImmutableList();
|
|
}
|
|
}
|
|
|
|
|
|
protected virtual IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user)
|
|
protected virtual IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user)
|
|
@@ -1369,7 +1371,7 @@ namespace MediaBrowser.Controller.Entities
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public virtual IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query)
|
|
|
|
|
|
+ public virtual IReadOnlyList<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query)
|
|
{
|
|
{
|
|
ArgumentNullException.ThrowIfNull(user);
|
|
ArgumentNullException.ThrowIfNull(user);
|
|
|
|
|
|
@@ -1377,35 +1379,35 @@ namespace MediaBrowser.Controller.Entities
|
|
|
|
|
|
AddChildren(user, true, result, true, query);
|
|
AddChildren(user, true, result, true, query);
|
|
|
|
|
|
- return result.Values;
|
|
|
|
|
|
+ return result.Values.ToImmutableList();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Gets the recursive children.
|
|
/// Gets the recursive children.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns>IList{BaseItem}.</returns>
|
|
/// <returns>IList{BaseItem}.</returns>
|
|
- public IList<BaseItem> GetRecursiveChildren()
|
|
|
|
|
|
+ public IReadOnlyList<BaseItem> GetRecursiveChildren()
|
|
{
|
|
{
|
|
return GetRecursiveChildren(true);
|
|
return GetRecursiveChildren(true);
|
|
}
|
|
}
|
|
|
|
|
|
- public IList<BaseItem> GetRecursiveChildren(bool includeLinkedChildren)
|
|
|
|
|
|
+ public IReadOnlyList<BaseItem> GetRecursiveChildren(bool includeLinkedChildren)
|
|
{
|
|
{
|
|
return GetRecursiveChildren(i => true, includeLinkedChildren);
|
|
return GetRecursiveChildren(i => true, includeLinkedChildren);
|
|
}
|
|
}
|
|
|
|
|
|
- public IList<BaseItem> GetRecursiveChildren(Func<BaseItem, bool> filter)
|
|
|
|
|
|
+ public IReadOnlyList<BaseItem> GetRecursiveChildren(Func<BaseItem, bool> filter)
|
|
{
|
|
{
|
|
return GetRecursiveChildren(filter, true);
|
|
return GetRecursiveChildren(filter, true);
|
|
}
|
|
}
|
|
|
|
|
|
- public IList<BaseItem> GetRecursiveChildren(Func<BaseItem, bool> filter, bool includeLinkedChildren)
|
|
|
|
|
|
+ public IReadOnlyList<BaseItem> GetRecursiveChildren(Func<BaseItem, bool> filter, bool includeLinkedChildren)
|
|
{
|
|
{
|
|
var result = new Dictionary<Guid, BaseItem>();
|
|
var result = new Dictionary<Guid, BaseItem>();
|
|
|
|
|
|
AddChildrenToList(result, includeLinkedChildren, true, filter);
|
|
AddChildrenToList(result, includeLinkedChildren, true, filter);
|
|
|
|
|
|
- return result.Values.ToList();
|
|
|
|
|
|
+ return result.Values.ToImmutableList();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -1556,11 +1558,12 @@ namespace MediaBrowser.Controller.Entities
|
|
/// Gets the linked children.
|
|
/// Gets the linked children.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns>IEnumerable{BaseItem}.</returns>
|
|
/// <returns>IEnumerable{BaseItem}.</returns>
|
|
- public IEnumerable<Tuple<LinkedChild, BaseItem>> GetLinkedChildrenInfos()
|
|
|
|
|
|
+ public IReadOnlyList<Tuple<LinkedChild, BaseItem>> GetLinkedChildrenInfos()
|
|
{
|
|
{
|
|
return LinkedChildren
|
|
return LinkedChildren
|
|
.Select(i => new Tuple<LinkedChild, BaseItem>(i, GetLinkedChild(i)))
|
|
.Select(i => new Tuple<LinkedChild, BaseItem>(i, GetLinkedChild(i)))
|
|
- .Where(i => i.Item2 is not null);
|
|
|
|
|
|
+ .Where(i => i.Item2 is not null)
|
|
|
|
+ .ToImmutableList();
|
|
}
|
|
}
|
|
|
|
|
|
protected override async Task<bool> RefreshedOwnedItems(MetadataRefreshOptions options, IReadOnlyList<FileSystemMetadata> fileSystemChildren, CancellationToken cancellationToken)
|
|
protected override async Task<bool> RefreshedOwnedItems(MetadataRefreshOptions options, IReadOnlyList<FileSystemMetadata> fileSystemChildren, CancellationToken cancellationToken)
|