From 2646ce696b59919774657348cd98544e7c3cf034 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 29 Jul 2013 12:03:19 -0400 Subject: [PATCH] fixes #388 - LibraryChanged message not reporting ItemsRemoved properly --- .../EntryPoints/LibraryChangedNotifier.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs index 02ecb4fca8..1306017ca1 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs @@ -46,7 +46,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints /// /// The library update duration /// - private const int LibraryUpdateDuration = 60000; + private const int LibraryUpdateDuration = 20000; public LibraryChangedNotifier(ILibraryManager libraryManager, ISessionManager sessionManager, IServerManager serverManager, IUserManager userManager, ILogger logger) { @@ -239,7 +239,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints ItemsUpdated = itemsUpdated.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren)).Select(i => i.Id).Distinct().ToList(), - ItemsRemoved = itemsRemoved.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren)).Select(i => i.Id).Distinct().ToList(), + ItemsRemoved = itemsRemoved.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren, true)).Select(i => i.Id).Distinct().ToList(), FoldersAddedTo = foldersAddedTo.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren)).Select(i => i.Id).Distinct().ToList(), @@ -255,14 +255,15 @@ namespace MediaBrowser.Server.Implementations.EntryPoints /// The user. /// The collections. /// All recursive children. + /// if set to true [include if not found]. /// IEnumerable{``0}. - private IEnumerable TranslatePhysicalItemToUserLibrary(T item, User user, IEnumerable collections, Dictionary allRecursiveChildren) + private IEnumerable TranslatePhysicalItemToUserLibrary(T item, User user, IEnumerable collections, Dictionary allRecursiveChildren, bool includeIfNotFound = false) where T : BaseItem { // If the physical root changed, return the user root if (item is AggregateFolder) { - return new T[] { user.RootFolder as T }; + return new[] { user.RootFolder as T }; } // Need to find what user collection folder this belongs to @@ -300,9 +301,9 @@ namespace MediaBrowser.Server.Implementations.EntryPoints } // Return it only if it's in the user's library - if (allRecursiveChildren.ContainsKey(item.Id)) + if (includeIfNotFound || allRecursiveChildren.ContainsKey(item.Id)) { - return new T[] { item }; + return new[] { item }; } return new T[] { };