mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 18:08:53 -07:00
improve boxset & playlist performance
This commit is contained in:
parent
6164049919
commit
037c4e8740
@ -67,6 +67,31 @@ namespace MediaBrowser.Controller.Entities
|
||||
return CreateResolveArgs(directoryService, true).FileSystemChildren;
|
||||
}
|
||||
|
||||
private List<Guid> _childrenIds = null;
|
||||
private readonly object _childIdsLock = new object();
|
||||
protected override IEnumerable<BaseItem> LoadChildren()
|
||||
{
|
||||
lock (_childIdsLock)
|
||||
{
|
||||
if (_childrenIds == null || _childrenIds.Count == 0)
|
||||
{
|
||||
var list = base.LoadChildren().ToList();
|
||||
_childrenIds = list.Select(i => i.Id).ToList();
|
||||
return list;
|
||||
}
|
||||
|
||||
return _childrenIds.Select(LibraryManager.GetItemById).Where(i => i != null).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetCachedChildren()
|
||||
{
|
||||
lock (_childIdsLock)
|
||||
{
|
||||
_childrenIds = null;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _requiresRefresh;
|
||||
public override bool RequiresRefresh()
|
||||
{
|
||||
@ -89,6 +114,8 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
public override bool BeforeMetadataRefresh()
|
||||
{
|
||||
ResetCachedChildren();
|
||||
|
||||
var changed = base.BeforeMetadataRefresh() || _requiresRefresh;
|
||||
_requiresRefresh = false;
|
||||
return changed;
|
||||
@ -96,9 +123,11 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService, bool setPhysicalLocations)
|
||||
{
|
||||
ResetCachedChildren();
|
||||
|
||||
var path = ContainingFolderPath;
|
||||
|
||||
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths , directoryService)
|
||||
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, directoryService)
|
||||
{
|
||||
FileInfo = FileSystem.GetDirectoryInfo(path),
|
||||
Path = path,
|
||||
@ -135,7 +164,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds the virtual child.
|
||||
/// </summary>
|
||||
|
@ -273,7 +273,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// </summary>
|
||||
protected virtual IEnumerable<BaseItem> LoadChildren()
|
||||
{
|
||||
//Logger.Debug("Loading children from {0} {1}", Id, Path);
|
||||
//Logger.Debug("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
|
||||
return GetCachedChildren();
|
||||
}
|
||||
|
@ -62,11 +62,18 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||
return UnratedItem.Movie;
|
||||
}
|
||||
|
||||
protected override IEnumerable<BaseItem> GetNonCachedChildren(IDirectoryService directoryService)
|
||||
{
|
||||
if (IsLegacyBoxSet)
|
||||
{
|
||||
return base.LoadChildren();
|
||||
}
|
||||
return new List<BaseItem>();
|
||||
}
|
||||
|
||||
protected override IEnumerable<BaseItem> LoadChildren()
|
||||
{
|
||||
var first = LinkedChildren.FirstOrDefault();
|
||||
|
||||
if (first != null && first.Type == LinkedChildType.Shortcut)
|
||||
if (IsLegacyBoxSet)
|
||||
{
|
||||
return base.LoadChildren();
|
||||
}
|
||||
@ -89,7 +96,22 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
if (IsLegacyBoxSet)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
private bool IsLegacyBoxSet
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
|
||||
namespace MediaBrowser.Controller.Playlists
|
||||
{
|
||||
@ -69,6 +70,11 @@ namespace MediaBrowser.Controller.Playlists
|
||||
return GetPlayableItems(user).Result;
|
||||
}
|
||||
|
||||
protected override IEnumerable<BaseItem> GetNonCachedChildren(IDirectoryService directoryService)
|
||||
{
|
||||
return new List<BaseItem>();
|
||||
}
|
||||
|
||||
public override IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query)
|
||||
{
|
||||
var items = GetPlayableItems(user).Result;
|
||||
|
Loading…
Reference in New Issue
Block a user