diff --git a/MediaBrowser.Controller/Channels/ChannelAudioItem.cs b/MediaBrowser.Controller/Channels/ChannelAudioItem.cs index 7582f4c91..82fe66c7b 100644 --- a/MediaBrowser.Controller/Channels/ChannelAudioItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelAudioItem.cs @@ -104,7 +104,7 @@ namespace MediaBrowser.Controller.Channels public override bool IsVisibleStandalone(User user) { - return base.IsVisibleStandalone(user) && ChannelVideoItem.IsChannelVisible(this, user); + return IsVisibleStandaloneInternal(user, false) && ChannelVideoItem.IsChannelVisible(this, user); } } } diff --git a/MediaBrowser.Controller/Channels/ChannelFolderItem.cs b/MediaBrowser.Controller/Channels/ChannelFolderItem.cs index 43f5160a4..641d37161 100644 --- a/MediaBrowser.Controller/Channels/ChannelFolderItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelFolderItem.cs @@ -83,7 +83,7 @@ namespace MediaBrowser.Controller.Channels public override bool IsVisibleStandalone(User user) { - return base.IsVisibleStandalone(user) && ChannelVideoItem.IsChannelVisible(this, user); + return IsVisibleStandaloneInternal(user, false) && ChannelVideoItem.IsChannelVisible(this, user); } } } diff --git a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs b/MediaBrowser.Controller/Channels/ChannelVideoItem.cs index d97341d8f..ef3cc7cba 100644 --- a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelVideoItem.cs @@ -133,7 +133,7 @@ namespace MediaBrowser.Controller.Channels public override bool IsVisibleStandalone(User user) { - return base.IsVisibleStandalone(user) && IsChannelVisible(this, user); + return IsVisibleStandaloneInternal(user, false) && IsChannelVisible(this, user); } internal static bool IsChannelVisible(IChannelItem item, User user) diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index f8384ea1c..a1bcde9e6 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1143,6 +1143,11 @@ namespace MediaBrowser.Controller.Entities } public virtual bool IsVisibleStandalone(User user) + { + return IsVisibleStandaloneInternal(user, true); + } + + protected bool IsVisibleStandaloneInternal(User user, bool checkFolders) { if (!IsVisible(user)) { @@ -1154,17 +1159,25 @@ namespace MediaBrowser.Controller.Entities return false; } - var topParent = Parents.LastOrDefault() ?? this; - - if (string.IsNullOrWhiteSpace(topParent.Path)) + if (checkFolders) { - return true; + var topParent = Parents.LastOrDefault() ?? this; + + if (string.IsNullOrWhiteSpace(topParent.Path)) + { + return true; + } + + var userCollectionFolders = user.RootFolder.GetChildren(user, true).Select(i => i.Id).ToList(); + var itemCollectionFolders = LibraryManager.GetCollectionFolders(this).Select(i => i.Id); + + if (!itemCollectionFolders.Any(userCollectionFolders.Contains)) + { + return false; + } } - var folders = user.RootFolder.GetChildren(user, true).Select(i => i.Id).ToList(); - var itemCollectionFolders = LibraryManager.GetCollectionFolders(this).Select(i => i.Id).ToList(); - - return itemCollectionFolders.Any(folders.Contains); + return true; } /// @@ -1669,7 +1682,7 @@ namespace MediaBrowser.Controller.Entities else { existing.DateModified = FileSystem.GetLastWriteTimeUtc(newImage); - existing.Length = ((FileInfo) newImage).Length; + existing.Length = ((FileInfo)newImage).Length; } } diff --git a/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs index 1ffaf5b8c..b1bc5dbe5 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs @@ -243,19 +243,17 @@ namespace MediaBrowser.Server.Implementations.EntryPoints { var user = _userManager.GetUserById(userId); - var collections = user.RootFolder.GetChildren(user, true).ToList(); - return new LibraryUpdateInfo { - ItemsAdded = itemsAdded.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections)).Select(i => i.Id.ToString("N")).Distinct().ToList(), + ItemsAdded = itemsAdded.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToList(), - ItemsUpdated = itemsUpdated.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections)).Select(i => i.Id.ToString("N")).Distinct().ToList(), + ItemsUpdated = itemsUpdated.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToList(), - ItemsRemoved = itemsRemoved.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, true)).Select(i => i.Id.ToString("N")).Distinct().ToList(), + ItemsRemoved = itemsRemoved.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, true)).Select(i => i.Id.ToString("N")).Distinct().ToList(), - FoldersAddedTo = foldersAddedTo.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections)).Select(i => i.Id.ToString("N")).Distinct().ToList(), + FoldersAddedTo = foldersAddedTo.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToList(), - FoldersRemovedFrom = foldersRemovedFrom.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections)).Select(i => i.Id.ToString("N")).Distinct().ToList() + FoldersRemovedFrom = foldersRemovedFrom.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToList() }; } @@ -265,10 +263,9 @@ namespace MediaBrowser.Server.Implementations.EntryPoints /// /// The item. /// The user. - /// The collections. /// if set to true [include if not found]. /// IEnumerable{``0}. - private IEnumerable TranslatePhysicalItemToUserLibrary(T item, User user, IEnumerable collections, bool includeIfNotFound = false) + private IEnumerable TranslatePhysicalItemToUserLibrary(T item, User user, bool includeIfNotFound = false) where T : BaseItem { // If the physical root changed, return the user root @@ -277,15 +274,6 @@ namespace MediaBrowser.Server.Implementations.EntryPoints return new[] { user.RootFolder as T }; } - // Need to find what user collection folder this belongs to - if (item.Parent is AggregateFolder) - { - if (item.LocationType == LocationType.FileSystem) - { - return collections.Where(i => i.PhysicalLocations.Contains(item.Path)).Cast(); - } - } - // Return it only if it's in the user's library if (includeIfNotFound || item.IsVisibleStandalone(user)) {