瀏覽代碼

stop searching for dead shortcuts over and over

Luke Pulverenti 11 年之前
父節點
當前提交
88965f75e2
共有 2 個文件被更改,包括 20 次插入3 次删除
  1. 19 2
      MediaBrowser.Controller/Entities/Folder.cs
  2. 1 1
      MediaBrowser.Controller/Entities/LinkedChild.cs

+ 19 - 2
MediaBrowser.Controller/Entities/Folder.cs

@@ -893,9 +893,14 @@ namespace MediaBrowser.Controller.Entities
             BaseItem item = null;
 
             // First get using the cached Id
-            if (info.ItemId != Guid.Empty)
+            if (info.ItemId.HasValue)
             {
-                item = LibraryManager.GetItemById(info.ItemId);
+                if (info.ItemId.Value == Guid.Empty)
+                {
+                    return null;
+                }
+
+                item = LibraryManager.GetItemById(info.ItemId.Value);
             }
 
             // If still null, search by path
@@ -908,6 +913,9 @@ namespace MediaBrowser.Controller.Entities
             if (item == null)
             {
                 Logger.Warn("Unable to find linked item at {0}", info.Path);
+
+                // Don't keep searching over and over
+                info.ItemId = Guid.Empty;
             }
             else
             {
@@ -985,6 +993,15 @@ namespace MediaBrowser.Controller.Entities
                 return true;
             }
 
+            foreach (var child in LinkedChildren)
+            {
+                // Reset the cached value
+                if (child.ItemId.HasValue && child.ItemId.Value == Guid.Empty)
+                {
+                    child.ItemId = null;
+                }
+            }
+
             return false;
         }
 

+ 1 - 1
MediaBrowser.Controller/Entities/LinkedChild.cs

@@ -13,7 +13,7 @@ namespace MediaBrowser.Controller.Entities
         /// Serves as a cache
         /// </summary>
         [IgnoreDataMember]
-        public Guid ItemId { get; set; }
+        public Guid? ItemId { get; set; }
     }
 
     public enum LinkedChildType