diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-08-15 12:35:41 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-08-15 12:35:41 -0400 |
| commit | e3c86944718d68806ad42c4d14c964a72da90b44 (patch) | |
| tree | 521f7cf81f29ac302ce5545cdc5ecde66f977182 /MediaBrowser.Controller/Entities/Folder.cs | |
| parent | 9c5cceb4ecc277ffb5a3a988f655ad674bf41c58 (diff) | |
3.0.5340.20849
Diffstat (limited to 'MediaBrowser.Controller/Entities/Folder.cs')
| -rw-r--r-- | MediaBrowser.Controller/Entities/Folder.cs | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 96a8c579e..79c96dd5e 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -934,19 +934,50 @@ namespace MediaBrowser.Controller.Entities public IEnumerable<BaseItem> GetLinkedChildren(User user) { - if (!FilterLinkedChildrenPerUser) + if (!FilterLinkedChildrenPerUser || user == null) { return GetLinkedChildren(); } var locations = user.RootFolder - .Children + .GetChildren(user, true) .OfType<CollectionFolder>() .SelectMany(i => i.PhysicalLocations) .ToList(); - return LinkedChildren.Where(i => string.IsNullOrWhiteSpace(i.Path) || locations.Any(l => FileSystem.ContainsSubPath(l, i.Path))) - .Select(GetLinkedChild) + return LinkedChildren + .Select(i => + { + var requiresPostFilter = true; + + if (!string.IsNullOrWhiteSpace(i.Path)) + { + requiresPostFilter = false; + + if (!locations.Any(l => FileSystem.ContainsSubPath(l, i.Path))) + { + return null; + } + } + + var child = GetLinkedChild(i); + + if (requiresPostFilter && child != null) + { + if (string.IsNullOrWhiteSpace(child.Path)) + { + Logger.Debug("Found LinkedChild with null path: {0}", child.Name); + return child; + } + + if (!locations.Any(l => FileSystem.ContainsSubPath(l, child.Path))) + { + return null; + } + } + + return child; + }) .Where(i => i != null); } |
