From 17106ea5c72511f5871178c7f1def629c20191ac Mon Sep 17 00:00:00 2001 From: ebr11 Eric Reed spam Date: Mon, 17 Sep 2012 11:12:43 -0400 Subject: Initial commit changing to on-demand child loading and validations --- MediaBrowser.Controller/Entities/BaseItem.cs | 21 ++ MediaBrowser.Controller/Entities/Folder.cs | 300 +++++++++++++++++++++++++-- 2 files changed, 302 insertions(+), 19 deletions(-) (limited to 'MediaBrowser.Controller/Entities') diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 68a192065f..d135acf9cf 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -134,6 +134,27 @@ namespace MediaBrowser.Controller.Entities } } + /// + /// Determine if we have changed vs the passed in copy + /// + /// + /// + public virtual bool IsChanged(BaseItem original) + { + bool changed = original.DateModified != this.DateModified; + changed |= original.DateCreated != this.DateCreated; + return changed; + } + + /// + /// Refresh metadata on us by execution our provider chain + /// + /// true if a provider reports we changed + public bool RefreshMetadata() + { + return false; + } + /// /// Determines if the item is considered new based on user settings /// diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index a9c92c1fa4..0858500f0d 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -1,5 +1,10 @@ using MediaBrowser.Model.Entities; +using MediaBrowser.Controller.IO; +using MediaBrowser.Controller.Library; +using MediaBrowser.Common.Logging; +using MediaBrowser.Controller.Resolvers; using System; +using System.Threading.Tasks; using System.Collections.Generic; using System.Linq; @@ -7,6 +12,24 @@ namespace MediaBrowser.Controller.Entities { public class Folder : BaseItem { + #region Events + /// + /// Fires whenever a validation routine updates our children. The added and removed children are properties of the args. + /// *** Will fire asynchronously. *** + /// + public event EventHandler ChildrenChanged; + protected void OnChildrenChanged(ChildrenChangedEventArgs args) + { + if (ChildrenChanged != null) + { + Task.Run( () => ChildrenChanged(this, args)); + } + } + + #endregion + + public IEnumerable PhysicalLocations { get; set; } + public override bool IsFolder { get @@ -24,23 +47,262 @@ namespace MediaBrowser.Controller.Entities return Parent != null && Parent.IsRoot; } } + protected object childLock = new object(); + protected List children; + protected virtual List ActualChildren + { + get + { + if (children == null) + { + LoadChildren(); + } + return children; + } + + set + { + children = value; + } + } + + /// + /// thread-safe access to the actual children of this folder - without regard to user + /// + public IEnumerable Children + { + get + { + lock (childLock) + return ActualChildren.ToList(); + } + } + + /// + /// thread-safe access to all recursive children of this folder - without regard to user + /// + public IEnumerable RecursiveChildren + { + get + { + foreach (var item in Children) + { + yield return item; + + var subFolder = item as Folder; + + if (subFolder != null) + { + foreach (var subitem in subFolder.RecursiveChildren) + { + yield return subitem; + } + } + } + } + } + + + /// + /// Loads and validates our children + /// + protected virtual void LoadChildren() + { + //first - load our children from the repo + lock (childLock) + children = GetCachedChildren(); + + //then kick off a validation against the actual file system + Task.Run(() => ValidateChildren()); + } + + protected bool ChildrenValidating = false; - public IEnumerable Children { get; set; } + /// + /// Compare our current children (presumably just read from the repo) with the current state of the file system and adjust for any changes + /// ***Currently does not contain logic to maintain items that are unavailable in the file system*** + /// + /// + protected async virtual void ValidateChildren() + { + if (ChildrenValidating) return; //only ever want one of these going at once and don't want them to fire off in sequence so don't use lock + ChildrenValidating = true; + bool changed = false; //this will save us a little time at the end if nothing changes + var changedArgs = new ChildrenChangedEventArgs(this); + //get the current valid children from filesystem (or wherever) + var nonCachedChildren = await GetNonCachedChildren(); + if (nonCachedChildren == null) return; //nothing to validate + //build a dictionary of the current children we have now by Id so we can compare quickly and easily + Dictionary currentChildren; + lock (childLock) + currentChildren = ActualChildren.ToDictionary(i => i.Id); + + //create a list for our validated children + var validChildren = new List(); + //now traverse the valid children and find any changed or new items + foreach (var child in nonCachedChildren) + { + BaseItem currentChild; + currentChildren.TryGetValue(child.Id, out currentChild); + if (currentChild == null) + { + //brand new item - needs to be added + changed = true; + changedArgs.ItemsAdded.Add(child); + //Logger.LogInfo("New Item Added to Library: ("+child.GetType().Name+")"+ child.Name + "(" + child.Path + ")"); + //refresh it + child.RefreshMetadata(); + //save it in repo... + + //and add it to our valid children + validChildren.Add(child); + //fire an added event...? + //if it is a folder we need to validate its children as well + Folder folder = child as Folder; + if (folder != null) + { + folder.ValidateChildren(); + //probably need to refresh too... + } + } + else + { + //existing item - check if it has changed + if (currentChild.IsChanged(child)) + { + changed = true; + currentChild.RefreshMetadata(); + //save it in repo... + validChildren.Add(currentChild); + } + else + { + //current child that didn't change - just put it in the valid children + validChildren.Add(currentChild); + } + } + } + + //that's all the new and changed ones - now see if there are any that are missing + changedArgs.ItemsRemoved = currentChildren.Values.Except(validChildren); + changed |= changedArgs.ItemsRemoved != null; + + //now, if anything changed - replace our children + if (changed) + { + lock (childLock) + ActualChildren = validChildren; + //and save children in repo... + + //and fire event + this.OnChildrenChanged(changedArgs); + } + ChildrenValidating = false; + + } + + /// + /// Get the children of this folder from the actual file system + /// + /// + protected async virtual Task> GetNonCachedChildren() + { + ItemResolveEventArgs args = new ItemResolveEventArgs() + { + FileInfo = FileData.GetFileData(this.Path), + Parent = this.Parent, + Cancel = false, + Path = this.Path + }; + + // Gather child folder and files + if (args.IsDirectory) + { + args.FileSystemChildren = FileData.GetFileSystemEntries(this.Path, "*").ToArray(); + + bool isVirtualFolder = Parent != null && Parent.IsRoot; + args = FileSystemHelper.FilterChildFileSystemEntries(args, isVirtualFolder); + } + else + { + Logger.LogError("Folder has a path that is not a directory: " + this.Path); + return null; + } + + if (!EntityResolutionHelper.ShouldResolvePathContents(args)) + { + return null; + } + return (await Task.WhenAll(GetChildren(args.FileSystemChildren)).ConfigureAwait(false)) + .Where(i => i != null).OrderBy(f => + { + return string.IsNullOrEmpty(f.SortName) ? f.Name : f.SortName; + + }); + + } + + /// + /// Resolves a path into a BaseItem + /// + protected async Task GetChild(string path, WIN32_FIND_DATA? fileInfo = null) + { + ItemResolveEventArgs args = new ItemResolveEventArgs() + { + FileInfo = fileInfo ?? FileData.GetFileData(path), + Parent = this, + Cancel = false, + Path = path + }; + + args.FileSystemChildren = FileData.GetFileSystemEntries(path, "*").ToArray(); + args = FileSystemHelper.FilterChildFileSystemEntries(args, false); + + return Kernel.Instance.ResolveItem(args); + + } + + /// + /// Finds child BaseItems for a given Folder + /// + protected Task[] GetChildren(WIN32_FIND_DATA[] fileSystemChildren) + { + Task[] tasks = new Task[fileSystemChildren.Length]; + + for (int i = 0; i < fileSystemChildren.Length; i++) + { + var child = fileSystemChildren[i]; + + tasks[i] = GetChild(child.Path, child); + } + + return tasks; + } + + + /// + /// Get our children from the repo - stubbed for now + /// + /// + protected virtual List GetCachedChildren() + { + return new List(); + } /// /// Gets allowed children of an item /// - public IEnumerable GetParentalAllowedChildren(User user) + public IEnumerable GetChildren(User user) { - return Children.Where(c => c.IsParentalAllowed(user)); + return ActualChildren.Where(c => c.IsParentalAllowed(user)); } /// /// Gets allowed recursive children of an item /// - public IEnumerable GetParentalAllowedRecursiveChildren(User user) + public IEnumerable GetRecursiveChildren(User user) { - foreach (var item in GetParentalAllowedChildren(user)) + foreach (var item in GetChildren(user)) { yield return item; @@ -48,7 +310,7 @@ namespace MediaBrowser.Controller.Entities if (subFolder != null) { - foreach (var subitem in subFolder.GetParentalAllowedRecursiveChildren(user)) + foreach (var subitem in subFolder.GetRecursiveChildren(user)) { yield return subitem; } @@ -63,7 +325,7 @@ namespace MediaBrowser.Controller.Entities { ItemSpecialCounts counts = new ItemSpecialCounts(); - IEnumerable recursiveChildren = GetParentalAllowedRecursiveChildren(user); + IEnumerable recursiveChildren = GetRecursiveChildren(user); counts.RecentlyAddedItemCount = GetRecentlyAddedItems(recursiveChildren, user).Count(); counts.RecentlyAddedUnPlayedItemCount = GetRecentlyAddedUnplayedItems(recursiveChildren, user).Count(); @@ -78,7 +340,7 @@ namespace MediaBrowser.Controller.Entities /// public IEnumerable GetItemsWithGenre(string genre, User user) { - return GetParentalAllowedRecursiveChildren(user).Where(f => f.Genres != null && f.Genres.Any(s => s.Equals(genre, StringComparison.OrdinalIgnoreCase))); + return GetRecursiveChildren(user).Where(f => f.Genres != null && f.Genres.Any(s => s.Equals(genre, StringComparison.OrdinalIgnoreCase))); } /// @@ -86,7 +348,7 @@ namespace MediaBrowser.Controller.Entities /// public IEnumerable GetItemsWithYear(int year, User user) { - return GetParentalAllowedRecursiveChildren(user).Where(f => f.ProductionYear.HasValue && f.ProductionYear == year); + return GetRecursiveChildren(user).Where(f => f.ProductionYear.HasValue && f.ProductionYear == year); } /// @@ -94,7 +356,7 @@ namespace MediaBrowser.Controller.Entities /// public IEnumerable GetItemsWithStudio(string studio, User user) { - return GetParentalAllowedRecursiveChildren(user).Where(f => f.Studios != null && f.Studios.Any(s => s.Equals(studio, StringComparison.OrdinalIgnoreCase))); + return GetRecursiveChildren(user).Where(f => f.Studios != null && f.Studios.Any(s => s.Equals(studio, StringComparison.OrdinalIgnoreCase))); } /// @@ -102,7 +364,7 @@ namespace MediaBrowser.Controller.Entities /// public IEnumerable GetFavoriteItems(User user) { - return GetParentalAllowedRecursiveChildren(user).Where(c => + return GetRecursiveChildren(user).Where(c => { UserItemData data = c.GetUserData(user, false); @@ -120,7 +382,7 @@ namespace MediaBrowser.Controller.Entities /// public IEnumerable GetItemsWithPerson(string person, User user) { - return GetParentalAllowedRecursiveChildren(user).Where(c => + return GetRecursiveChildren(user).Where(c => { if (c.People != null) { @@ -137,7 +399,7 @@ namespace MediaBrowser.Controller.Entities /// Specify this to limit results to a specific PersonType public IEnumerable GetItemsWithPerson(string person, string personType, User user) { - return GetParentalAllowedRecursiveChildren(user).Where(c => + return GetRecursiveChildren(user).Where(c => { if (c.People != null) { @@ -153,7 +415,7 @@ namespace MediaBrowser.Controller.Entities /// public IEnumerable GetRecentlyAddedItems(User user) { - return GetRecentlyAddedItems(GetParentalAllowedRecursiveChildren(user), user); + return GetRecentlyAddedItems(GetRecursiveChildren(user), user); } /// @@ -161,7 +423,7 @@ namespace MediaBrowser.Controller.Entities /// public IEnumerable GetRecentlyAddedUnplayedItems(User user) { - return GetRecentlyAddedUnplayedItems(GetParentalAllowedRecursiveChildren(user), user); + return GetRecentlyAddedUnplayedItems(GetRecursiveChildren(user), user); } /// @@ -169,7 +431,7 @@ namespace MediaBrowser.Controller.Entities /// public IEnumerable GetInProgressItems(User user) { - return GetInProgressItems(GetParentalAllowedRecursiveChildren(user), user); + return GetInProgressItems(GetRecursiveChildren(user), user); } /// @@ -257,7 +519,7 @@ namespace MediaBrowser.Controller.Entities base.SetPlayedStatus(user, wasPlayed); // Now sweep through recursively and update status - foreach (BaseItem item in GetParentalAllowedChildren(user)) + foreach (BaseItem item in GetChildren(user)) { item.SetPlayedStatus(user, wasPlayed); } @@ -275,7 +537,7 @@ namespace MediaBrowser.Controller.Entities return result; } - foreach (BaseItem item in Children) + foreach (BaseItem item in ActualChildren) { result = item.FindItemById(id); @@ -298,7 +560,7 @@ namespace MediaBrowser.Controller.Entities return this; } - foreach (BaseItem item in Children) + foreach (BaseItem item in ActualChildren) { var folder = item as Folder; -- cgit v1.2.3 From 7cfa489c6ea7887982d4cb7643e23631448421e5 Mon Sep 17 00:00:00 2001 From: ebr11 Eric Reed spam Date: Mon, 17 Sep 2012 12:55:58 -0400 Subject: Attach ItemResolveEventArgs to BaseItem so providers can access them at any time --- MediaBrowser.Controller/Entities/BaseItem.cs | 8 ++++++++ MediaBrowser.Controller/Entities/Folder.cs | 4 ++++ MediaBrowser.Controller/Kernel.cs | 2 ++ 3 files changed, 14 insertions(+) (limited to 'MediaBrowser.Controller/Entities') diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index d135acf9cf..17f32c0e6d 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1,4 +1,5 @@ using MediaBrowser.Model.Entities; +using MediaBrowser.Controller.Library; using System; using System.Collections.Generic; using System.Linq; @@ -7,6 +8,13 @@ namespace MediaBrowser.Controller.Entities { public abstract class BaseItem : BaseEntity, IHasProviderIds { + /// + /// We attach these to the item so that we only ever have to hit the file system once + /// (this includes the children of the containing folder) + /// Use ResolveArgs.FileSystemChildren to check for the existence of files instead of File.Exists + /// + public ItemResolveEventArgs ResolveArgs { get; set; } + public string SortName { get; set; } /// diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 0858500f0d..1e099e14d8 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -171,6 +171,10 @@ namespace MediaBrowser.Controller.Entities if (currentChild.IsChanged(child)) { changed = true; + //update resolve args and refresh meta + // Note - we are refreshing the existing child instead of the newly found one so the "Except" operation below + // will identify this item as the same one + currentChild.ResolveArgs = child.ResolveArgs; currentChild.RefreshMetadata(); //save it in repo... validChildren.Add(currentChild); diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs index 13010ad8ec..e7b8435bb9 100644 --- a/MediaBrowser.Controller/Kernel.cs +++ b/MediaBrowser.Controller/Kernel.cs @@ -129,6 +129,7 @@ namespace MediaBrowser.Controller if (item != null) { + item.ResolveArgs = args; return item; } } @@ -160,6 +161,7 @@ namespace MediaBrowser.Controller void RootFolder_ChildrenChanged(object sender, ChildrenChangedEventArgs e) { + Logger.LogDebugInfo("Root Folder Children Changed. Added: " + e.ItemsAdded.Count + " Removed: " + e.ItemsRemoved.Count()); //re-start the directory watchers DirectoryWatchers.Stop(); DirectoryWatchers.Start(); -- cgit v1.2.3 From 922fd3acaed9c39849abcbfa60bc9040e791c383 Mon Sep 17 00:00:00 2001 From: ebr11 Eric Reed spam Date: Mon, 17 Sep 2012 13:05:42 -0400 Subject: Make ResolveArgs self-creating if need be --- MediaBrowser.Controller/Entities/BaseItem.cs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Controller/Entities') diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 17f32c0e6d..dc148da36b 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1,5 +1,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.IO; using System; using System.Collections.Generic; using System.Linq; @@ -8,12 +9,34 @@ namespace MediaBrowser.Controller.Entities { public abstract class BaseItem : BaseEntity, IHasProviderIds { + protected ItemResolveEventArgs _resolveArgs; /// /// We attach these to the item so that we only ever have to hit the file system once /// (this includes the children of the containing folder) /// Use ResolveArgs.FileSystemChildren to check for the existence of files instead of File.Exists /// - public ItemResolveEventArgs ResolveArgs { get; set; } + public ItemResolveEventArgs ResolveArgs + { + get + { + if (_resolveArgs == null) + { + _resolveArgs = new ItemResolveEventArgs() + { + FileInfo = FileData.GetFileData(this.Path), + Parent = this.Parent, + Cancel = false, + Path = this.Path + }; + _resolveArgs = FileSystemHelper.FilterChildFileSystemEntries(_resolveArgs, (this.Parent != null && this.Parent.IsRoot)); + } + return _resolveArgs; + } + set + { + _resolveArgs = value; + } + } public string SortName { get; set; } -- cgit v1.2.3 From 7186d661095ae935be3c74960d72a66548e41888 Mon Sep 17 00:00:00 2001 From: ebr11 Eric Reed spam Date: Mon, 17 Sep 2012 13:29:06 -0400 Subject: Add OnLibraryChanged event to server Kernel --- MediaBrowser.Controller/Entities/Folder.cs | 6 +++++- MediaBrowser.Controller/Kernel.cs | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Controller/Entities') diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 1e099e14d8..694ec1ca21 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -22,7 +22,11 @@ namespace MediaBrowser.Controller.Entities { if (ChildrenChanged != null) { - Task.Run( () => ChildrenChanged(this, args)); + Task.Run( () => + { + ChildrenChanged(this, args); + Kernel.Instance.OnLibraryChanged(args); + }); } } diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs index e7b8435bb9..b8243d65fe 100644 --- a/MediaBrowser.Controller/Kernel.cs +++ b/MediaBrowser.Controller/Kernel.cs @@ -25,6 +25,21 @@ namespace MediaBrowser.Controller { public class Kernel : BaseKernel { + #region Events + /// + /// Fires whenever any validation routine adds or removes items. The added and removed items are properties of the args. + /// *** Will fire asynchronously. *** + /// + public event EventHandler LibraryChanged; + public void OnLibraryChanged(ChildrenChangedEventArgs args) + { + if (LibraryChanged != null) + { + Task.Run(() => LibraryChanged(this, args)); + } + } + + #endregion public static Kernel Instance { get; private set; } public ItemController ItemController { get; private set; } -- cgit v1.2.3 From 946c0e8256d61d5084efdd2196eef455fa13b89b Mon Sep 17 00:00:00 2001 From: ebr11 Eric Reed spam Date: Mon, 17 Sep 2012 16:08:32 -0400 Subject: Initial metadata provider hook in. No refresh intelligence yet. --- MediaBrowser.Controller/Entities/BaseEntity.cs | 48 +++++++++++++++++++++++ MediaBrowser.Controller/Entities/BaseItem.cs | 42 -------------------- MediaBrowser.Controller/Kernel.cs | 9 ++--- MediaBrowser.Controller/Library/ItemController.cs | 2 +- 4 files changed, 53 insertions(+), 48 deletions(-) (limited to 'MediaBrowser.Controller/Entities') diff --git a/MediaBrowser.Controller/Entities/BaseEntity.cs b/MediaBrowser.Controller/Entities/BaseEntity.cs index 53b42da01d..7f0ea12b80 100644 --- a/MediaBrowser.Controller/Entities/BaseEntity.cs +++ b/MediaBrowser.Controller/Entities/BaseEntity.cs @@ -1,4 +1,8 @@ using System; +using System.Collections.Generic; +using System.Linq; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.IO; namespace MediaBrowser.Controller.Entities { @@ -11,6 +15,10 @@ namespace MediaBrowser.Controller.Entities public Guid Id { get; set; } + public string Path { get; set; } + + public Folder Parent { get; set; } + public string PrimaryImagePath { get; set; } public DateTime DateCreated { get; set; } @@ -21,5 +29,45 @@ namespace MediaBrowser.Controller.Entities { return Name; } + + protected ItemResolveEventArgs _resolveArgs; + /// + /// We attach these to the item so that we only ever have to hit the file system once + /// (this includes the children of the containing folder) + /// Use ResolveArgs.FileSystemChildren to check for the existence of files instead of File.Exists + /// + public ItemResolveEventArgs ResolveArgs + { + get + { + if (_resolveArgs == null) + { + _resolveArgs = new ItemResolveEventArgs() + { + FileInfo = FileData.GetFileData(this.Path), + Parent = this.Parent, + Cancel = false, + Path = this.Path + }; + _resolveArgs = FileSystemHelper.FilterChildFileSystemEntries(_resolveArgs, (this.Parent != null && this.Parent.IsRoot)); + } + return _resolveArgs; + } + set + { + _resolveArgs = value; + } + } + + /// + /// Refresh metadata on us by execution our provider chain + /// + /// true if a provider reports we changed + public bool RefreshMetadata() + { + Kernel.Instance.ExecuteMetadataProviders(this).ConfigureAwait(false); + return true; + } + } } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index dc148da36b..984584e9a5 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -9,35 +9,6 @@ namespace MediaBrowser.Controller.Entities { public abstract class BaseItem : BaseEntity, IHasProviderIds { - protected ItemResolveEventArgs _resolveArgs; - /// - /// We attach these to the item so that we only ever have to hit the file system once - /// (this includes the children of the containing folder) - /// Use ResolveArgs.FileSystemChildren to check for the existence of files instead of File.Exists - /// - public ItemResolveEventArgs ResolveArgs - { - get - { - if (_resolveArgs == null) - { - _resolveArgs = new ItemResolveEventArgs() - { - FileInfo = FileData.GetFileData(this.Path), - Parent = this.Parent, - Cancel = false, - Path = this.Path - }; - _resolveArgs = FileSystemHelper.FilterChildFileSystemEntries(_resolveArgs, (this.Parent != null && this.Parent.IsRoot)); - } - return _resolveArgs; - } - set - { - _resolveArgs = value; - } - } - public string SortName { get; set; } /// @@ -45,10 +16,6 @@ namespace MediaBrowser.Controller.Entities /// public DateTime? PremiereDate { get; set; } - public string Path { get; set; } - - public Folder Parent { get; set; } - public string LogoImagePath { get; set; } public string ArtImagePath { get; set; } @@ -177,15 +144,6 @@ namespace MediaBrowser.Controller.Entities return changed; } - /// - /// Refresh metadata on us by execution our provider chain - /// - /// true if a provider reports we changed - public bool RefreshMetadata() - { - return false; - } - /// /// Determines if the item is considered new based on user settings /// diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs index b8243d65fe..cf4450aec5 100644 --- a/MediaBrowser.Controller/Kernel.cs +++ b/MediaBrowser.Controller/Kernel.cs @@ -118,9 +118,6 @@ namespace MediaBrowser.Controller //watch the root folder children for changes RootFolder.ChildrenChanged += RootFolder_ChildrenChanged; - System.Threading.Thread.Sleep(25000); - var allChildren = RootFolder.RecursiveChildren; - Logger.LogInfo(string.Format("Loading complete. Movies: {0} Episodes: {1}", allChildren.OfType().Count(), allChildren.OfType().Count())); } protected override void OnComposablePartsLoaded() @@ -180,6 +177,8 @@ namespace MediaBrowser.Controller //re-start the directory watchers DirectoryWatchers.Stop(); DirectoryWatchers.Start(); + var allChildren = RootFolder.RecursiveChildren; + Logger.LogInfo(string.Format("Loading complete. Movies: {0} Episodes: {1}", allChildren.OfType().Count(), allChildren.OfType().Count())); } /// @@ -328,7 +327,7 @@ namespace MediaBrowser.Controller /// /// Runs all metadata providers for an entity /// - internal async Task ExecuteMetadataProviders(BaseEntity item, ItemResolveEventArgs args, bool allowInternetProviders = true) + internal async Task ExecuteMetadataProviders(BaseEntity item, bool allowInternetProviders = true) { // Run them sequentially in order of priority for (int i = 0; i < MetadataProviders.Length; i++) @@ -349,7 +348,7 @@ namespace MediaBrowser.Controller try { - await provider.FetchAsync(item, args).ConfigureAwait(false); + await provider.FetchAsync(item, item.ResolveArgs).ConfigureAwait(false); } catch (Exception ex) { diff --git a/MediaBrowser.Controller/Library/ItemController.cs b/MediaBrowser.Controller/Library/ItemController.cs index 7ef1c17a11..dd08c193e7 100644 --- a/MediaBrowser.Controller/Library/ItemController.cs +++ b/MediaBrowser.Controller/Library/ItemController.cs @@ -217,7 +217,7 @@ namespace MediaBrowser.Controller.Library args.FileInfo = FileData.GetFileData(path); args.FileSystemChildren = FileData.GetFileSystemEntries(path, "*").ToArray(); - await Kernel.Instance.ExecuteMetadataProviders(item, args).ConfigureAwait(false); + await Kernel.Instance.ExecuteMetadataProviders(item).ConfigureAwait(false); return item; } -- cgit v1.2.3