improve shortcut performance

This commit is contained in:
Luke Pulverenti
2013-10-03 11:24:32 -04:00
parent 16fd474ad3
commit d021e20249
3 changed files with 38 additions and 18 deletions

View File

@@ -4,7 +4,6 @@ using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Localization;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Model.Entities;
using System;
@@ -1140,12 +1139,30 @@ namespace MediaBrowser.Controller.Entities
throw new ArgumentException("Encountered linked child with empty path.");
}
var item = LibraryManager.RootFolder.FindByPath(info.Path);
BaseItem item = null;
// First get using the cached Id
if (info.ItemId != Guid.Empty)
{
item = LibraryManager.GetItemById(info.ItemId);
}
// If still null, search by path
if (item == null)
{
item = LibraryManager.RootFolder.FindByPath(info.Path);
}
// If still null, log
if (item == null)
{
Logger.Warn("Unable to find linked item at {0}", info.Path);
}
else
{
// Cache the id for next time
info.ItemId = item.Id;
}
return item;
}
@@ -1215,7 +1232,7 @@ namespace MediaBrowser.Controller.Entities
.Where(i => i != null)
.ToList();
if (!newShortcutLinks.SequenceEqual(currentShortcutLinks))
if (!newShortcutLinks.SequenceEqual(currentShortcutLinks, new LinkedChildComparer()))
{
Logger.Info("Shortcut links have changed for {0}", Path);