diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index db3e546d1..ae6ef6340 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1042,7 +1042,9 @@ namespace MediaBrowser.Controller.Entities throw new ArgumentNullException("user"); } - if (user.Configuration.MaxParentalRating == null) + var maxAllowedRating = user.Configuration.MaxParentalRating; + + if (maxAllowedRating == null) { return true; } @@ -1067,7 +1069,7 @@ namespace MediaBrowser.Controller.Entities return true; } - return value.Value <= user.Configuration.MaxParentalRating.Value; + return value.Value <= maxAllowedRating.Value; } /// diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 252b4d0a8..d14ee2228 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -476,7 +476,7 @@ namespace MediaBrowser.Controller.Entities { get { - LazyInitializer.EnsureInitialized(ref _children, ref _childrenInitialized, ref _childrenSyncLock, LoadChildren); + LazyInitializer.EnsureInitialized(ref _children, ref _childrenInitialized, ref _childrenSyncLock, LoadChildrenInternal); return _children; } private set @@ -529,16 +529,20 @@ namespace MediaBrowser.Controller.Entities } } + private ConcurrentDictionary LoadChildrenInternal() + { + return new ConcurrentDictionary(LoadChildren().ToDictionary(i => i.Id)); + } /// /// Loads our children. Validation will occur externally. /// We want this sychronous. /// /// ConcurrentBag{BaseItem}. - protected virtual ConcurrentDictionary LoadChildren() + protected virtual IEnumerable LoadChildren() { //just load our children from the repo - the library will be validated and maintained in other processes - return new ConcurrentDictionary(GetCachedChildren().ToDictionary(i => i.Id)); + return GetCachedChildren(); } /// diff --git a/MediaBrowser.Controller/Entities/IndexFolder.cs b/MediaBrowser.Controller/Entities/IndexFolder.cs index 6b88ea1fc..57e4a35d3 100644 --- a/MediaBrowser.Controller/Entities/IndexFolder.cs +++ b/MediaBrowser.Controller/Entities/IndexFolder.cs @@ -1,7 +1,6 @@ using MediaBrowser.Common.Extensions; using MediaBrowser.Model.Entities; using MoreLinq; -using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; @@ -111,7 +110,7 @@ namespace MediaBrowser.Controller.Entities /// Override to return the children defined to us when we were created /// /// The actual children. - protected override ConcurrentDictionary LoadChildren() + protected override IEnumerable LoadChildren() { var originalChildSource = ChildSource.ToList(); @@ -136,7 +135,7 @@ namespace MediaBrowser.Controller.Entities // Now - since we built the index grouping from the bottom up - we now need to properly set Parents from the top down SetParents(this, kids.OfType()); - return new ConcurrentDictionary(kids.DistinctBy(i => i.Id).ToDictionary(i => i.Id)); + return kids.DistinctBy(i => i.Id); } ///