From 4e90d732039c578a0994706938a2e34a7cb2d4c5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Sep 2015 22:31:40 -0400 Subject: [PATCH] update search --- MediaBrowser.Controller/Entities/Folder.cs | 23 +++++++++++-------- .../Entities/InternalItemsQuery.cs | 2 ++ .../Library/LibraryManager.cs | 4 ++++ .../Persistence/SqliteItemRepository.cs | 6 +++++ .../MediaBrowser.WebDashboard.csproj | 6 +++++ 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 04d42e16f3..3b00d50be4 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -763,21 +763,24 @@ namespace MediaBrowser.Controller.Entities /// IEnumerable{BaseItem}. protected IEnumerable GetCachedChildren() { - var childrenItems = ItemRepository.GetChildrenItems(Id).Select(RetrieveChild).Where(i => i != null); - - //var children = ItemRepository.GetChildren(Id).Select(RetrieveChild).Where(i => i != null).ToList(); - - //if (children.Count != childrenItems.Count) - //{ - // var b = this; - //} + if (ConfigurationManager.Configuration.DisableStartupScan) + { + return ItemRepository.GetChildrenItems(Id).Select(RetrieveChild).Where(i => i != null); + //return ItemRepository.GetItems(new InternalItemsQuery + //{ + // ParentId = Id - return childrenItems; + //}).Items.Select(RetrieveChild).Where(i => i != null); + } + else + { + return ItemRepository.GetChildrenItems(Id).Select(RetrieveChild).Where(i => i != null); + } } private BaseItem RetrieveChild(BaseItem child) { - if (child.Id == Guid.Empty) + if (child == null || child.Id == Guid.Empty) { Logger.Error("Item found with empty Id: " + (child.Path ?? child.Name)); return null; diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index bde4d0f457..e2d9d9a58f 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -101,6 +101,8 @@ namespace MediaBrowser.Controller.Entities public bool? IsOffline { get; set; } public LocationType? LocationType { get; set; } + public Guid? ParentId { get; set; } + public InternalItemsQuery() { Tags = new string[] { }; diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 966c1e0378..0be871b0e1 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -354,6 +354,10 @@ namespace MediaBrowser.Server.Implementations.Library return; } } + //if (!(item is Folder)) + //{ + // return; + //} LibraryItemsCache.AddOrUpdate(id, item, delegate { return item; }); } diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index adadea894c..ce1a91791e 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -1202,6 +1202,12 @@ namespace MediaBrowser.Server.Implementations.Persistence whereClauses.Add(string.Format("ChannelId in ({0})", inClause)); } + if (query.ParentId.HasValue) + { + whereClauses.Add("ParentId=@ParentId"); + cmd.Parameters.Add(cmd, "@ParentId", DbType.Guid).Value = query.ParentId.Value; + } + if (query.MinEndDate.HasValue) { whereClauses.Add("EndDate>=@MinEndDate"); diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 57e52a254b..3a2f0c7e19 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -309,6 +309,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -330,6 +333,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest