diff options
Diffstat (limited to 'MediaBrowser.Controller/Entities/CollectionFolder.cs')
| -rw-r--r-- | MediaBrowser.Controller/Entities/CollectionFolder.cs | 85 |
1 files changed, 48 insertions, 37 deletions
diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index 6d619ce04..bc50ce618 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; @@ -69,64 +68,76 @@ namespace MediaBrowser.Controller.Entities return NullTaskResult; } + private List<LinkedChild> _linkedChildren; + /// <summary> /// Our children are actually just references to the ones in the physical root... /// </summary> /// <value>The linked children.</value> public override List<LinkedChild> LinkedChildren { - get + get { return _linkedChildren ?? (_linkedChildren = GetLinkedChildrenInternal()); } + set { - Dictionary<string, string> locationsDicionary; - - try - { - locationsDicionary = ResolveArgs.PhysicalLocations.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); - } - catch (IOException ex) - { - Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path); - return new List<LinkedChild>(); - } - - return LibraryManager.RootFolder.Children - .OfType<Folder>() - .Where(i => i.Path != null && locationsDicionary.ContainsKey(i.Path)) - .SelectMany(c => c.LinkedChildren).ToList(); + base.LinkedChildren = value; + } + } + private List<LinkedChild> GetLinkedChildrenInternal() + { + Dictionary<string, string> locationsDicionary; + try + { + locationsDicionary = ResolveArgs.PhysicalLocations.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); } - set + catch (IOException ex) { - base.LinkedChildren = value; + Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path); + return new List<LinkedChild>(); } + + return LibraryManager.RootFolder.Children + .OfType<Folder>() + .Where(i => i.Path != null && locationsDicionary.ContainsKey(i.Path)) + .SelectMany(c => c.LinkedChildren).ToList(); } + private IEnumerable<BaseItem> _actualChildren; + /// <summary> /// Our children are actually just references to the ones in the physical root... /// </summary> /// <value>The actual children.</value> protected override IEnumerable<BaseItem> ActualChildren { - get - { - Dictionary<string, string> locationsDicionary; + get { return _actualChildren ?? (_actualChildren = GetActualChildren()); } + } - try - { - locationsDicionary = ResolveArgs.PhysicalLocations.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); - } - catch (IOException ex) - { - Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path); - return new BaseItem[] { }; - } + private IEnumerable<BaseItem> GetActualChildren() + { + Dictionary<string, string> locationsDicionary; - return - LibraryManager.RootFolder.Children - .OfType<Folder>() - .Where(i => i.Path != null && locationsDicionary.ContainsKey(i.Path)) - .SelectMany(c => c.Children); + try + { + locationsDicionary = ResolveArgs.PhysicalLocations.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); } + catch (IOException ex) + { + Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path); + return new BaseItem[] { }; + } + + return + LibraryManager.RootFolder.Children + .OfType<Folder>() + .Where(i => i.Path != null && locationsDicionary.ContainsKey(i.Path)) + .SelectMany(c => c.Children); + } + + public void ResetDynamicChildren() + { + _actualChildren = null; + _linkedChildren = null; } } } |
