diff options
| author | Eric Reed <ebr@mediabrowser3.com> | 2013-06-20 12:19:55 -0400 |
|---|---|---|
| committer | Eric Reed <ebr@mediabrowser3.com> | 2013-06-20 12:19:55 -0400 |
| commit | a8d070d07bc59979eb6531bf56c1bbdb0e6a9df3 (patch) | |
| tree | 2a7fa8357c63397e95df0a072cea5e3d6564c15b /MediaBrowser.Controller/IO/FileData.cs | |
| parent | b02287c0dd6d2f58b4559ae05a9972665ea13521 (diff) | |
| parent | 6f15aeccd0946f19145cc063a8982d585b77df91 (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Diffstat (limited to 'MediaBrowser.Controller/IO/FileData.cs')
| -rw-r--r-- | MediaBrowser.Controller/IO/FileData.cs | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.cs index 8896d4fc1..306de1e3c 100644 --- a/MediaBrowser.Controller/IO/FileData.cs +++ b/MediaBrowser.Controller/IO/FileData.cs @@ -3,6 +3,7 @@ using MediaBrowser.Model.Logging; using System; using System.Collections.Generic; using System.IO; +using System.Linq; namespace MediaBrowser.Controller.IO { @@ -29,22 +30,29 @@ namespace MediaBrowser.Controller.IO throw new ArgumentNullException("path"); } - var dict = new Dictionary<string, FileSystemInfo>(StringComparer.OrdinalIgnoreCase); - var entries = new DirectoryInfo(path).EnumerateFileSystemInfos(searchPattern, SearchOption.TopDirectoryOnly); + if (!resolveShortcuts && flattenFolderDepth == 0) + { + return entries.ToDictionary(i => i.FullName, StringComparer.OrdinalIgnoreCase); + } + + var dict = new Dictionary<string, FileSystemInfo>(StringComparer.OrdinalIgnoreCase); + foreach (var entry in entries) { var isDirectory = (entry.Attributes & FileAttributes.Directory) == FileAttributes.Directory; - if (resolveShortcuts && FileSystem.IsShortcut(entry.FullName)) + var fullName = entry.FullName; + + if (resolveShortcuts && FileSystem.IsShortcut(fullName)) { - var newPath = FileSystem.ResolveShortcut(entry.FullName); + var newPath = FileSystem.ResolveShortcut(fullName); if (string.IsNullOrWhiteSpace(newPath)) { //invalid shortcut - could be old or target could just be unavailable - logger.Warn("Encountered invalid shortcut: " + entry.FullName); + logger.Warn("Encountered invalid shortcut: " + fullName); continue; } @@ -57,18 +65,18 @@ namespace MediaBrowser.Controller.IO args.AddAdditionalLocation(newPath); } - dict[data.FullName] = data; + dict[newPath] = data; } else if (flattenFolderDepth > 0 && isDirectory) { - foreach (var child in GetFilteredFileSystemEntries(entry.FullName, logger, flattenFolderDepth: flattenFolderDepth - 1, resolveShortcuts: resolveShortcuts)) + foreach (var child in GetFilteredFileSystemEntries(fullName, logger, flattenFolderDepth: flattenFolderDepth - 1, resolveShortcuts: resolveShortcuts)) { dict[child.Key] = child.Value; } } else { - dict[entry.FullName] = entry; + dict[fullName] = entry; } } |
