mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 03:26:07 +02:00
improve boxset & playlist performance
This commit is contained in:
parent
6164049919
commit
037c4e8740
4 changed files with 64 additions and 7 deletions
|
@ -67,6 +67,31 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return CreateResolveArgs(directoryService, true).FileSystemChildren;
|
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;
|
private bool _requiresRefresh;
|
||||||
public override bool RequiresRefresh()
|
public override bool RequiresRefresh()
|
||||||
{
|
{
|
||||||
|
@ -89,6 +114,8 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
public override bool BeforeMetadataRefresh()
|
public override bool BeforeMetadataRefresh()
|
||||||
{
|
{
|
||||||
|
ResetCachedChildren();
|
||||||
|
|
||||||
var changed = base.BeforeMetadataRefresh() || _requiresRefresh;
|
var changed = base.BeforeMetadataRefresh() || _requiresRefresh;
|
||||||
_requiresRefresh = false;
|
_requiresRefresh = false;
|
||||||
return changed;
|
return changed;
|
||||||
|
@ -96,9 +123,11 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService, bool setPhysicalLocations)
|
private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService, bool setPhysicalLocations)
|
||||||
{
|
{
|
||||||
|
ResetCachedChildren();
|
||||||
|
|
||||||
var path = ContainingFolderPath;
|
var path = ContainingFolderPath;
|
||||||
|
|
||||||
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths , directoryService)
|
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, directoryService)
|
||||||
{
|
{
|
||||||
FileInfo = FileSystem.GetDirectoryInfo(path),
|
FileInfo = FileSystem.GetDirectoryInfo(path),
|
||||||
Path = path,
|
Path = path,
|
||||||
|
|
|
@ -273,7 +273,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual IEnumerable<BaseItem> LoadChildren()
|
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
|
//just load our children from the repo - the library will be validated and maintained in other processes
|
||||||
return GetCachedChildren();
|
return GetCachedChildren();
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,11 +62,18 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||||
return UnratedItem.Movie;
|
return UnratedItem.Movie;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IEnumerable<BaseItem> GetNonCachedChildren(IDirectoryService directoryService)
|
||||||
|
{
|
||||||
|
if (IsLegacyBoxSet)
|
||||||
|
{
|
||||||
|
return base.LoadChildren();
|
||||||
|
}
|
||||||
|
return new List<BaseItem>();
|
||||||
|
}
|
||||||
|
|
||||||
protected override IEnumerable<BaseItem> LoadChildren()
|
protected override IEnumerable<BaseItem> LoadChildren()
|
||||||
{
|
{
|
||||||
var first = LinkedChildren.FirstOrDefault();
|
if (IsLegacyBoxSet)
|
||||||
|
|
||||||
if (first != null && first.Type == LinkedChildType.Shortcut)
|
|
||||||
{
|
{
|
||||||
return base.LoadChildren();
|
return base.LoadChildren();
|
||||||
}
|
}
|
||||||
|
@ -89,7 +96,22 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||||
{
|
{
|
||||||
get
|
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.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Controller.Providers;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Playlists
|
namespace MediaBrowser.Controller.Playlists
|
||||||
{
|
{
|
||||||
|
@ -69,6 +70,11 @@ namespace MediaBrowser.Controller.Playlists
|
||||||
return GetPlayableItems(user).Result;
|
return GetPlayableItems(user).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IEnumerable<BaseItem> GetNonCachedChildren(IDirectoryService directoryService)
|
||||||
|
{
|
||||||
|
return new List<BaseItem>();
|
||||||
|
}
|
||||||
|
|
||||||
public override IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query)
|
public override IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
var items = GetPlayableItems(user).Result;
|
var items = GetPlayableItems(user).Result;
|
||||||
|
|
Loading…
Reference in a new issue