diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-08-06 17:11:07 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-06 17:11:07 -0400 |
| commit | 801aa02a4c4c61e3ac5eb2888c89d361edc3c295 (patch) | |
| tree | 1b214c5b683bdbe05d4725169e77c6126ba53157 /MediaBrowser.Controller | |
| parent | a571ee38ceafc0a1f30ded3f5bd2c6aba1d940da (diff) | |
| parent | 894d87fabb812152c76443afcf1739fda7c578ff (diff) | |
Merge pull request #2030 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.Controller')
| -rw-r--r-- | MediaBrowser.Controller/Providers/DirectoryService.cs | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/MediaBrowser.Controller/Providers/DirectoryService.cs b/MediaBrowser.Controller/Providers/DirectoryService.cs index ca9038439e..ee2b28c60a 100644 --- a/MediaBrowser.Controller/Providers/DirectoryService.cs +++ b/MediaBrowser.Controller/Providers/DirectoryService.cs @@ -16,7 +16,10 @@ namespace MediaBrowser.Controller.Providers private readonly ConcurrentDictionary<string, Dictionary<string, FileSystemMetadata>> _cache = new ConcurrentDictionary<string, Dictionary<string, FileSystemMetadata>>(StringComparer.OrdinalIgnoreCase); - public DirectoryService(ILogger logger, IFileSystem fileSystem) + private readonly ConcurrentDictionary<string, FileSystemMetadata> _fileCache = + new ConcurrentDictionary<string, FileSystemMetadata>(StringComparer.OrdinalIgnoreCase); + + public DirectoryService(ILogger logger, IFileSystem fileSystem) { _logger = logger; _fileSystem = fileSystem; @@ -100,29 +103,19 @@ namespace MediaBrowser.Controller.Providers public FileSystemMetadata GetFile(string path) { - return _fileSystem.GetFileInfo(path); - //var directory = Path.GetDirectoryName(path); - - //if (string.IsNullOrWhiteSpace(directory)) - //{ - // _logger.Debug("Parent path is null for {0}", path); - // return null; - //} - - //try - //{ - // var dict = GetFileSystemDictionary(directory, false); - - // FileSystemMetadata entry; - // dict.TryGetValue(path, out entry); - - // return entry; - //} - //catch (Exception ex) - //{ - // _logger.ErrorException("Error in GetFileSystemDictionary. Directory: :{0}. Original path: {1}", ex, directory, path); - // return null; - //} + FileSystemMetadata file; + if (!_fileCache.TryGetValue(path, out file)) + { + file = _fileSystem.GetFileInfo(path); + + if (file != null) + { + _fileCache.TryAdd(path, file); + } + } + + return file; + //return _fileSystem.GetFileInfo(path); } public IEnumerable<FileSystemMetadata> GetDirectories(string path) |
