diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index a2d045a5f0..f7963c6e69 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -338,10 +338,12 @@ namespace MediaBrowser.Controller.Entities if (args.IsDirectory) { + var isPhysicalRoot = args.IsPhysicalRoot; + // When resolving the root, we need it's grandchildren (children of user views) - var flattenFolderDepth = args.IsPhysicalRoot ? 2 : 0; + var flattenFolderDepth = isPhysicalRoot ? 2 : 0; - args.FileSystemDictionary = FileData.GetFilteredFileSystemEntries(args.Path, Logger, flattenFolderDepth: flattenFolderDepth, args: args); + args.FileSystemDictionary = FileData.GetFilteredFileSystemEntries(args.Path, Logger, flattenFolderDepth: flattenFolderDepth, args: args, resolveShortcuts: isPhysicalRoot || args.IsVf); } //update our dates diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.cs index 7cefcd71ad..4571c1ad0b 100644 --- a/MediaBrowser.Controller/IO/FileData.cs +++ b/MediaBrowser.Controller/IO/FileData.cs @@ -21,11 +21,12 @@ namespace MediaBrowser.Controller.IO /// if set to true [include files]. /// if set to true [include directories]. /// The flatten folder depth. + /// if set to true [resolve shortcuts]. /// The args. /// Dictionary{System.StringWIN32_FIND_DATA}. /// /// GetFileSystemEntries failed - public static Dictionary GetFilteredFileSystemEntries(string path, ILogger logger, string searchPattern = "*", bool includeFiles = true, bool includeDirectories = true, int flattenFolderDepth = 0, ItemResolveArgs args = null) + public static Dictionary GetFilteredFileSystemEntries(string path, ILogger logger, string searchPattern = "*", bool includeFiles = true, bool includeDirectories = true, int flattenFolderDepth = 0, bool resolveShortcuts = true, ItemResolveArgs args = null) { if (string.IsNullOrEmpty(path)) { @@ -80,7 +81,7 @@ namespace MediaBrowser.Controller.IO lpFindFileData.Path = Path.Combine(path, lpFindFileData.cFileName); - if (FileSystem.IsShortcut(lpFindFileData.Path)) + if (resolveShortcuts && FileSystem.IsShortcut(lpFindFileData.Path)) { var newPath = FileSystem.ResolveShortcut(lpFindFileData.Path); if (string.IsNullOrWhiteSpace(newPath)) @@ -110,7 +111,7 @@ namespace MediaBrowser.Controller.IO } else if (flattenFolderDepth > 0 && lpFindFileData.IsDirectory) { - foreach (var child in GetFilteredFileSystemEntries(lpFindFileData.Path, logger, flattenFolderDepth: flattenFolderDepth - 1)) + foreach (var child in GetFilteredFileSystemEntries(lpFindFileData.Path, logger, flattenFolderDepth: flattenFolderDepth - 1, resolveShortcuts: resolveShortcuts)) { dict[child.Key] = child.Value; } diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 46e8b261fb..e1d2e42b5a 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -413,10 +413,12 @@ namespace MediaBrowser.Server.Implementations.Library // Gather child folder and files if (args.IsDirectory) { + var isPhysicalRoot = args.IsPhysicalRoot; + // When resolving the root, we need it's grandchildren (children of user views) - var flattenFolderDepth = args.IsPhysicalRoot ? 2 : 0; + var flattenFolderDepth = isPhysicalRoot ? 2 : 0; - args.FileSystemDictionary = FileData.GetFilteredFileSystemEntries(args.Path, _logger, flattenFolderDepth: flattenFolderDepth, args: args); + args.FileSystemDictionary = FileData.GetFilteredFileSystemEntries(args.Path, _logger, flattenFolderDepth: flattenFolderDepth, args: args, resolveShortcuts: isPhysicalRoot || args.IsVf); } // Check to see if we should resolve based on our contents