mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-18 20:24:20 +01:00
fixes #97 and creates a library dictionary cache to avoid FindById recursion
This commit is contained in:
@@ -950,33 +950,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
return IsParentalAllowed(user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds an item by ID, recursively
|
||||
/// </summary>
|
||||
/// <param name="id">The id.</param>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <returns>BaseItem.</returns>
|
||||
/// <exception cref="System.ArgumentNullException">id</exception>
|
||||
public virtual BaseItem FindItemById(Guid id, User user)
|
||||
{
|
||||
if (id == Guid.Empty)
|
||||
{
|
||||
throw new ArgumentNullException("id");
|
||||
}
|
||||
|
||||
if (Id == id)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
if (LocalTrailers != null)
|
||||
{
|
||||
return LocalTrailers.FirstOrDefault(i => i.Id == id);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the particular item by searching through our parents and, if not found there, loading from repo
|
||||
/// </summary>
|
||||
|
||||
@@ -673,7 +673,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
foreach (var item in changedArgs.ItemsRemoved)
|
||||
{
|
||||
Logger.Info("** " + item.Name + " Removed from library.");
|
||||
Logger.Debug("** " + item.Name + " Removed from library.");
|
||||
}
|
||||
|
||||
var childrenReplaced = false;
|
||||
@@ -688,7 +688,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
foreach (var item in changedArgs.ItemsAdded)
|
||||
{
|
||||
Logger.Info("** " + item.Name + " Added to library.");
|
||||
Logger.Debug("** " + item.Name + " Added to library.");
|
||||
|
||||
if (!childrenReplaced)
|
||||
{
|
||||
@@ -701,7 +701,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
await Task.WhenAll(saveTasks).ConfigureAwait(false);
|
||||
|
||||
//and save children in repo...
|
||||
Logger.Info("*** Saving " + newChildren.Count + " children for " + Name);
|
||||
Logger.Debug("*** Saving " + newChildren.Count + " children for " + Name);
|
||||
await Kernel.Instance.ItemRepository.SaveChildren(Id, newChildren, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -913,36 +913,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds an item by ID, recursively
|
||||
/// </summary>
|
||||
/// <param name="id">The id.</param>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <returns>BaseItem.</returns>
|
||||
public override BaseItem FindItemById(Guid id, User user)
|
||||
{
|
||||
var result = base.FindItemById(id, user);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
var children = user == null ? ActualChildren : GetChildren(user);
|
||||
|
||||
foreach (var child in children)
|
||||
{
|
||||
result = child.FindItemById(id, user);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds an item by path, recursively
|
||||
/// </summary>
|
||||
|
||||
@@ -118,30 +118,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds an item by ID, recursively
|
||||
/// </summary>
|
||||
/// <param name="id">The id.</param>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <returns>BaseItem.</returns>
|
||||
public override BaseItem FindItemById(Guid id, User user)
|
||||
{
|
||||
var item = base.FindItemById(id, user);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
||||
if (SpecialFeatures != null)
|
||||
{
|
||||
return SpecialFeatures.FirstOrDefault(i => i.Id == id);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads special features from the file system
|
||||
|
||||
Reference in New Issue
Block a user