diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 8ca004e466..136a13e08b 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -939,9 +939,6 @@ protected void RegisterResources() LibraryMonitor = new LibraryMonitor(LogManager, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager, TimerFactory, SystemEvents, EnvironmentInfo); RegisterSingleInstance(LibraryMonitor); - ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, LibraryMonitor, LogManager, FileSystemManager, ApplicationPaths, () => LibraryManager, JsonSerializer, MemoryStreamFactory); - RegisterSingleInstance(ProviderManager); - RegisterSingleInstance(() => new SearchEngine(LogManager, LibraryManager, UserManager)); CertificateInfo = GetCertificateInfo(true); @@ -963,9 +960,6 @@ protected void RegisterResources() SyncManager = CreateSyncManager(); RegisterSingleInstance(SyncManager); - DtoService = new DtoService(LogManager.GetLogger("DtoService"), LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this, () => DeviceManager, () => MediaSourceManager, () => LiveTvManager); - RegisterSingleInstance(DtoService); - var encryptionManager = new EncryptionManager(); RegisterSingleInstance(encryptionManager); @@ -981,12 +975,21 @@ protected void RegisterResources() var newsService = new Emby.Server.Implementations.News.NewsService(ApplicationPaths, JsonSerializer); RegisterSingleInstance(newsService); - ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, LogManager.GetLogger("ChannelManager"), ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, LocalizationManager, HttpClient, ProviderManager); - RegisterSingleInstance(ChannelManager); - MediaSourceManager = new MediaSourceManager(ItemRepository, UserManager, LibraryManager, LogManager.GetLogger("MediaSourceManager"), JsonSerializer, FileSystemManager, UserDataManager, TimerFactory, () => MediaEncoder); RegisterSingleInstance(MediaSourceManager); + SubtitleManager = new SubtitleManager(LogManager.GetLogger("SubtitleManager"), FileSystemManager, LibraryMonitor, MediaSourceManager, ServerConfigurationManager, LocalizationManager); + RegisterSingleInstance(SubtitleManager); + + ProviderManager = new ProviderManager(HttpClient, SubtitleManager, ServerConfigurationManager, LibraryMonitor, LogManager, FileSystemManager, ApplicationPaths, () => LibraryManager, JsonSerializer, MemoryStreamFactory); + RegisterSingleInstance(ProviderManager); + + DtoService = new DtoService(LogManager.GetLogger("DtoService"), LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this, () => DeviceManager, () => MediaSourceManager, () => LiveTvManager); + RegisterSingleInstance(DtoService); + + ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, LogManager.GetLogger("ChannelManager"), ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, LocalizationManager, HttpClient, ProviderManager); + RegisterSingleInstance(ChannelManager); + SessionManager = new SessionManager(UserDataManager, LogManager.GetLogger("SessionManager"), LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager, MediaSourceManager, TimerFactory); RegisterSingleInstance(SessionManager); @@ -1017,9 +1020,6 @@ protected void RegisterResources() NotificationManager = new NotificationManager(LogManager, UserManager, ServerConfigurationManager); RegisterSingleInstance(NotificationManager); - SubtitleManager = new SubtitleManager(LogManager.GetLogger("SubtitleManager"), FileSystemManager, LibraryMonitor, LibraryManager, MediaSourceManager, ServerConfigurationManager, LocalizationManager); - RegisterSingleInstance(SubtitleManager); - RegisterSingleInstance(new DeviceDiscovery(LogManager.GetLogger("IDeviceDiscovery"), ServerConfigurationManager, SocketFactory, TimerFactory)); ChapterManager = new ChapterManager(LibraryManager, LogManager.GetLogger("ChapterManager"), ServerConfigurationManager, ItemRepository); @@ -1403,7 +1403,6 @@ protected void FindParts() StartServer(); LibraryManager.AddParts(GetExports(), - GetExports(), GetExports(), GetExports(), GetExports(), diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index 4bf37ec019..5a8519bc71 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -481,7 +481,7 @@ private async Task GetChannel(IChannel channelInfo, CancellationToken c if (isNew) { item.OnMetadataChanged(); - _libraryManager.CreateItem(item); + _libraryManager.CreateItem(item, null); } await item.RefreshMetadata(new MetadataRefreshOptions(_fileSystem) @@ -720,7 +720,7 @@ public async Task> GetChannelItemsInternal(InternalItemsQu if (itemsResult != null) { var internalItems = itemsResult.Items - .Select(i => GetChannelItemEntity(i, channelProvider, channel.Id, parentItem.Id, cancellationToken)) + .Select(i => GetChannelItemEntity(i, channelProvider, channel.Id, parentItem, cancellationToken)) .ToArray(); var existingIds = _libraryManager.GetItemIds(query); @@ -934,8 +934,10 @@ private T GetItemById(string idString, string channelName, out bool isNew) return item; } - private BaseItem GetChannelItemEntity(ChannelItemInfo info, IChannel channelProvider, Guid internalChannelId, Guid parentFolderId, CancellationToken cancellationToken) + private BaseItem GetChannelItemEntity(ChannelItemInfo info, IChannel channelProvider, Guid internalChannelId, BaseItem parentFolder, CancellationToken cancellationToken) { + var parentFolderId = parentFolder.Id; + BaseItem item; bool isNew; bool forceUpdate = false; @@ -1156,7 +1158,7 @@ private BaseItem GetChannelItemEntity(ChannelItemInfo info, IChannel channelProv if (isNew) { - _libraryManager.CreateItem(item); + _libraryManager.CreateItem(item, parentFolder); if (info.People != null && info.People.Count > 0) { diff --git a/Emby.Server.Implementations/Collections/CollectionImageProvider.cs b/Emby.Server.Implementations/Collections/CollectionImageProvider.cs index 0a8ad8c9fc..858dada4b4 100644 --- a/Emby.Server.Implementations/Collections/CollectionImageProvider.cs +++ b/Emby.Server.Implementations/Collections/CollectionImageProvider.cs @@ -58,7 +58,7 @@ protected override List GetItemsWithImages(BaseItem item) return subItem; } - var parent = subItem.IsOwnedItem ? subItem.GetOwner() : subItem.GetParent(); + var parent = subItem.GetOwner() ?? subItem.GetParent(); if (parent != null && parent.HasImage(ImageType.Primary)) { diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 8afa286f5d..f4d75b8e97 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -811,7 +811,7 @@ private void SaveItem(BaseItem item, BaseItem topParent, string userDataKey, ISt saveItemStatement.TryBind("@ProductionYear", item.ProductionYear); var parentId = item.ParentId; - if (parentId == Guid.Empty) + if (parentId.Equals(Guid.Empty)) { saveItemStatement.TryBindNull("@ParentId"); } @@ -1251,7 +1251,7 @@ public ItemImageInfo ItemImageInfoFromValueString(string value) /// public BaseItem RetrieveItem(Guid id) { - if (id == Guid.Empty) + if (id.Equals(Guid.Empty)) { throw new ArgumentNullException("id"); } @@ -2044,7 +2044,7 @@ public void SaveCriticReviews(Guid itemId, IEnumerable criticReviews public List GetChapters(Guid id) { CheckDisposed(); - if (id == Guid.Empty) + if (id.Equals(Guid.Empty)) { throw new ArgumentNullException("id"); } @@ -2080,7 +2080,7 @@ public List GetChapters(Guid id) public ChapterInfo GetChapter(Guid id, int index) { CheckDisposed(); - if (id == Guid.Empty) + if (id.Equals(Guid.Empty)) { throw new ArgumentNullException("id"); } @@ -2141,7 +2141,7 @@ public void SaveChapters(Guid id, List chapters) { CheckDisposed(); - if (id == Guid.Empty) + if (id.Equals(Guid.Empty)) { throw new ArgumentNullException("id"); } @@ -4821,7 +4821,7 @@ private IEnumerable MapIncludeItemTypes(string value) public void DeleteItem(Guid id, CancellationToken cancellationToken) { - if (id == Guid.Empty) + if (id.Equals(Guid.Empty)) { throw new ArgumentNullException("id"); } @@ -5022,7 +5022,7 @@ private List GetPeopleWhereClauses(InternalPeopleQuery query, IStatement private void UpdateAncestors(Guid itemId, List ancestorIds, IDatabaseConnection db, IStatement deleteAncestorsStatement, IStatement updateAncestorsStatement) { - if (itemId == Guid.Empty) + if (itemId.Equals(Guid.Empty)) { throw new ArgumentNullException("itemId"); } @@ -5508,7 +5508,7 @@ private List> GetItemValuesToSave(BaseItem item, List private void UpdateItemValues(Guid itemId, List> values, IDatabaseConnection db) { - if (itemId == Guid.Empty) + if (itemId.Equals(Guid.Empty)) { throw new ArgumentNullException("itemId"); } @@ -5559,7 +5559,7 @@ private void UpdateItemValues(Guid itemId, List> values, IDat public void UpdatePeople(Guid itemId, List people) { - if (itemId == Guid.Empty) + if (itemId.Equals(Guid.Empty)) { throw new ArgumentNullException("itemId"); } @@ -5691,7 +5691,7 @@ public void SaveMediaStreams(Guid id, List streams, CancellationTok { CheckDisposed(); - if (id == Guid.Empty) + if (id.Equals(Guid.Empty)) { throw new ArgumentNullException("id"); } diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs index 1d4c869473..06b1c2ef47 100644 --- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs @@ -110,7 +110,7 @@ public void SaveUserData(Guid userId, string key, UserItemData userData, Cancell { throw new ArgumentNullException("userData"); } - if (userId == Guid.Empty) + if (userId.Equals(Guid.Empty)) { throw new ArgumentNullException("userId"); } @@ -128,7 +128,7 @@ public void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationTo { throw new ArgumentNullException("userData"); } - if (userId == Guid.Empty) + if (userId.Equals(Guid.Empty)) { throw new ArgumentNullException("userId"); } @@ -247,7 +247,7 @@ private void PersistAllUserData(Guid userId, UserItemData[] userDataList, Cancel /// public UserItemData GetUserData(Guid userId, string key) { - if (userId == Guid.Empty) + if (userId.Equals(Guid.Empty)) { throw new ArgumentNullException("userId"); } @@ -278,7 +278,7 @@ public UserItemData GetUserData(Guid userId, string key) public UserItemData GetUserData(Guid userId, List keys) { - if (userId == Guid.Empty) + if (userId.Equals(Guid.Empty)) { throw new ArgumentNullException("userId"); } @@ -302,7 +302,7 @@ public UserItemData GetUserData(Guid userId, List keys) /// public List GetAllUserData(Guid userId) { - if (userId == Guid.Empty) + if (userId.Equals(Guid.Empty)) { throw new ArgumentNullException("userId"); } diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index d0117b0207..5aee93bdad 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -1325,13 +1325,6 @@ private void AttachBasicFields(BaseItemDto dto, BaseItem item, BaseItem owner, D dto.IndexNumberEnd = episode.IndexNumberEnd; dto.SeriesName = episode.SeriesName; - if (fields.Contains(ItemFields.AlternateEpisodeNumbers)) - { - dto.DvdSeasonNumber = episode.DvdSeasonNumber; - dto.DvdEpisodeNumber = episode.DvdEpisodeNumber; - dto.AbsoluteEpisodeNumber = episode.AbsoluteEpisodeNumber; - } - if (fields.Contains(ItemFields.SpecialEpisodeNumbers)) { dto.AirsAfterSeasonNumber = episode.AirsAfterSeasonNumber; @@ -1480,7 +1473,7 @@ private BaseItem GetImageDisplayParent(BaseItem currentItem, BaseItem originalIt } } - var parent = currentItem.DisplayParent ?? (currentItem.IsOwnedItem ? currentItem.GetOwner() : currentItem.GetParent()); + var parent = currentItem.DisplayParent ?? currentItem.GetOwner() ?? currentItem.GetParent(); if (parent == null && !(originalItem is UserRootFolder) && !(originalItem is UserView) && !(originalItem is AggregateFolder) && !(originalItem is ICollectionFolder) && !(originalItem is Channel)) { diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 5f495f847b..5944973ace 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -430,7 +430,6 @@ - diff --git a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs index 7544c8179f..16f16a6009 100644 --- a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs @@ -77,7 +77,7 @@ void _userDataManager_UserDataSaved(object sender, UserDataSaveEventArgs e) // Go up one level for indicators if (baseItem != null) { - var parent = baseItem.IsOwnedItem ? baseItem.GetOwner() : baseItem.GetParent(); + var parent = baseItem.GetOwner() ?? baseItem.GetParent(); if (parent != null) { diff --git a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs index b6df78721c..a9c26d1045 100644 --- a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -351,7 +351,7 @@ private string SerializeToXmlString(object from) public object GetOptimizedResultUsingCache(IRequest requestContext, Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, Func factoryFn, IDictionary responseHeaders = null) where T : class { - if (cacheKey == Guid.Empty) + if (cacheKey.Equals(Guid.Empty)) { throw new ArgumentNullException("cacheKey"); } @@ -394,7 +394,7 @@ public object GetOptimizedResultUsingCache(IRequest requestContext, Guid cach public object GetCachedResult(IRequest requestContext, Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, Func factoryFn, string contentType, IDictionary responseHeaders = null) where T : class { - if (cacheKey == Guid.Empty) + if (cacheKey.Equals(Guid.Empty)) { throw new ArgumentNullException("cacheKey"); } @@ -551,7 +551,7 @@ public async Task GetStaticResult(IRequest requestContext, StaticResultO options.ResponseHeaders = options.ResponseHeaders ?? new Dictionary(StringComparer.OrdinalIgnoreCase); var contentType = options.ContentType; - if (cacheKey == Guid.Empty) + if (cacheKey.Equals(Guid.Empty)) { throw new ArgumentNullException("cacheKey"); } diff --git a/Emby.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.cs index 35e2877a6c..4be30f8b74 100644 --- a/Emby.Server.Implementations/IO/FileRefresher.cs +++ b/Emby.Server.Implementations/IO/FileRefresher.cs @@ -202,7 +202,7 @@ private BaseItem GetAffectedBaseItem(string path) // If the item has been deleted find the first valid parent that still exists while (!_fileSystem.DirectoryExists(item.Path) && !_fileSystem.FileExists(item.Path)) { - item = item.IsOwnedItem ? item.GetOwner() : item.GetParent(); + item = item.GetOwner() ?? item.GetParent(); if (item == null) { @@ -231,7 +231,6 @@ public void Dispose() { _disposed = true; DisposeTimer(); - GC.SuppressFinalize(this); } } } diff --git a/Emby.Server.Implementations/IO/IsoManager.cs b/Emby.Server.Implementations/IO/IsoManager.cs index dc0b9e122e..903d5f301f 100644 --- a/Emby.Server.Implementations/IO/IsoManager.cs +++ b/Emby.Server.Implementations/IO/IsoManager.cs @@ -70,7 +70,6 @@ public void Dispose() { mounter.Dispose(); } - GC.SuppressFinalize(this); } } } diff --git a/Emby.Server.Implementations/IO/LibraryMonitor.cs b/Emby.Server.Implementations/IO/LibraryMonitor.cs index 35f72a2923..1cecb721e8 100644 --- a/Emby.Server.Implementations/IO/LibraryMonitor.cs +++ b/Emby.Server.Implementations/IO/LibraryMonitor.cs @@ -622,7 +622,6 @@ public void Dispose() { _disposed = true; Dispose(true); - GC.SuppressFinalize(this); } /// @@ -654,7 +653,6 @@ public void Run() public void Dispose() { - GC.SuppressFinalize(this); } } } diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 34b3fef4ba..a2638fa5e7 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -44,6 +44,7 @@ using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.LiveTv; using MediaBrowser.Model.Tasks; +using Emby.Server.Implementations.Playlists; namespace Emby.Server.Implementations.Library { @@ -70,12 +71,6 @@ public class LibraryManager : ILibraryManager /// The entity resolution ignore rules. private IResolverIgnoreRule[] EntityResolutionIgnoreRules { get; set; } - /// - /// Gets the list of BasePluginFolders added by plugins - /// - /// The plugin folders. - private IVirtualFolderCreator[] PluginFolderCreators { get; set; } - /// /// Gets the list of currently registered entity resolvers /// @@ -195,14 +190,12 @@ public LibraryManager(ILogger logger, ITaskManager taskManager, IUserManager use /// The item comparers. /// The postscan tasks. public void AddParts(IEnumerable rules, - IEnumerable pluginFolders, IEnumerable resolvers, IEnumerable introProviders, IEnumerable itemComparers, IEnumerable postscanTasks) { EntityResolutionIgnoreRules = rules.ToArray(); - PluginFolderCreators = pluginFolders.ToArray(); EntityResolvers = resolvers.OrderBy(i => i.Priority).ToArray(); MultiItemResolvers = EntityResolvers.OfType().ToArray(); IntroProviders = introProviders.ToArray(); @@ -323,7 +316,7 @@ public void DeleteItem(BaseItem item, DeleteOptions options, bool notifyParentIt throw new ArgumentNullException("item"); } - var parent = item.IsOwnedItem ? item.GetOwner() : item.GetParent(); + var parent = item.GetOwner() ?? item.GetParent(); DeleteItem(item, options, parent, notifyParentItem); } @@ -741,44 +734,45 @@ public AggregateFolder CreateRootFolder() _logger.Info("Resetting root folder path to {0}", rootFolderPath); rootFolder.Path = rootFolderPath; } - + // Add in the plug-in folders - foreach (var child in PluginFolderCreators) + var path = Path.Combine(ConfigurationManager.ApplicationPaths.DataPath, "playlists"); + + _fileSystem.CreateDirectory(path); + + Folder folder = new PlaylistsFolder { - var folder = child.GetFolder(); + Path = path + }; - if (folder != null) + if (folder.Id.Equals(Guid.Empty)) + { + if (string.IsNullOrEmpty(folder.Path)) { - if (folder.Id == Guid.Empty) - { - if (string.IsNullOrEmpty(folder.Path)) - { - folder.Id = GetNewItemId(folder.GetType().Name, folder.GetType()); - } - else - { - folder.Id = GetNewItemId(folder.Path, folder.GetType()); - } - } + folder.Id = GetNewItemId(folder.GetType().Name, folder.GetType()); + } + else + { + folder.Id = GetNewItemId(folder.Path, folder.GetType()); + } + } - var dbItem = GetItemById(folder.Id) as BasePluginFolder; + var dbItem = GetItemById(folder.Id) as BasePluginFolder; - if (dbItem != null && string.Equals(dbItem.Path, folder.Path, StringComparison.OrdinalIgnoreCase)) - { - folder = dbItem; - } + if (dbItem != null && string.Equals(dbItem.Path, folder.Path, StringComparison.OrdinalIgnoreCase)) + { + folder = dbItem; + } - if (folder.ParentId != rootFolder.Id) - { - folder.ParentId = rootFolder.Id; - folder.UpdateToRepository(ItemUpdateType.MetadataImport, CancellationToken.None); - } + if (folder.ParentId != rootFolder.Id) + { + folder.ParentId = rootFolder.Id; + folder.UpdateToRepository(ItemUpdateType.MetadataImport, CancellationToken.None); + } - rootFolder.AddVirtualChild(folder); + rootFolder.AddVirtualChild(folder); - RegisterItem(folder); - } - } + RegisterItem(folder); return rootFolder; } @@ -983,7 +977,7 @@ private T CreateItemByName(Func getPathFn, string name, DtoOp Path = path }; - CreateItem(item); + CreateItem(item, null); } return item; @@ -1244,7 +1238,7 @@ private string GetCollectionType(string path) /// id public BaseItem GetItemById(Guid id) { - if (id == Guid.Empty) + if (id.Equals(Guid.Empty)) { throw new ArgumentNullException("id"); } @@ -1827,9 +1821,9 @@ private IBaseItemComparer GetComparer(string name, User user) /// The item. /// The cancellation token. /// Task. - public void CreateItem(BaseItem item) + public void CreateItem(BaseItem item, BaseItem parent) { - CreateItems(new[] { item }, item.GetParent(), CancellationToken.None); + CreateItems(new[] { item }, parent, CancellationToken.None); } /// @@ -1885,7 +1879,7 @@ public void UpdateImages(BaseItem item) /// /// Updates the item. /// - public void UpdateItems(List items, ItemUpdateType updateReason, CancellationToken cancellationToken) + public void UpdateItems(List items, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken) { foreach (var item in items) { @@ -1919,7 +1913,7 @@ public void UpdateItems(List items, ItemUpdateType updateReason, Cance ItemUpdated(this, new ItemChangeEventArgs { Item = item, - Parent = item.GetParent(), + Parent = parent, UpdateReason = updateReason }); } @@ -1938,9 +1932,9 @@ public void UpdateItems(List items, ItemUpdateType updateReason, Cance /// The update reason. /// The cancellation token. /// Task. - public void UpdateItem(BaseItem item, ItemUpdateType updateReason, CancellationToken cancellationToken) + public void UpdateItem(BaseItem item, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken) { - UpdateItems(new List { item }, updateReason, cancellationToken); + UpdateItems(new List { item }, parent, updateReason, cancellationToken); } /// @@ -2108,9 +2102,14 @@ private string GetTopFolderContentType(BaseItem item) return null; } - while (!(item.GetParent() is AggregateFolder) && item.GetParent() != null) + while (!item.ParentId.Equals(Guid.Empty)) { - item = item.GetParent(); + var parent = item.GetParent(); + if (parent == null || parent is AggregateFolder) + { + break; + } + item = parent; } return GetUserRootFolder().Children @@ -2159,7 +2158,7 @@ public UserView GetNamedView(string name, ForcedSortName = sortName }; - CreateItem(item); + CreateItem(item, null); refresh = true; } @@ -2220,7 +2219,7 @@ public UserView GetNamedView(User user, item.DisplayParentId = new Guid(parentId); } - CreateItem(item); + CreateItem(item, null); isNew = true; } @@ -2284,7 +2283,7 @@ public UserView GetShadowView(BaseItem parent, item.DisplayParentId = parentId; - CreateItem(item); + CreateItem(item, null); isNew = true; } @@ -2354,7 +2353,7 @@ public UserView GetNamedView(string name, item.DisplayParentId = new Guid(parentId); } - CreateItem(item); + CreateItem(item, null); isNew = true; } @@ -2367,7 +2366,7 @@ public UserView GetNamedView(string name, var refresh = isNew || DateTime.UtcNow - item.DateLastRefreshed >= _viewRefreshInterval; - if (!refresh && item.DisplayParentId != Guid.Empty) + if (!refresh && !item.DisplayParentId.Equals(Guid.Empty)) { var displayParent = GetItemById(item.DisplayParentId); refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed; @@ -2662,7 +2661,7 @@ public IEnumerable