diff --git a/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs index 02ecb4fca..1306017ca 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[] { };