diff options
| author | Bond_009 <bond.009@outlook.com> | 2021-05-07 00:52:06 +0200 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2021-05-07 00:52:06 +0200 |
| commit | 4367b97a54f31233e242ef1afe6714b934ecf4d9 (patch) | |
| tree | 7152a38c3fd4ffdfa8d39ca2c1a28d01113f43b7 /MediaBrowser.Controller/Providers/DirectoryService.cs | |
| parent | fb090df0b59b71d7f143d2181d46f18943bbc35e (diff) | |
Fix build
Diffstat (limited to 'MediaBrowser.Controller/Providers/DirectoryService.cs')
| -rw-r--r-- | MediaBrowser.Controller/Providers/DirectoryService.cs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/MediaBrowser.Controller/Providers/DirectoryService.cs b/MediaBrowser.Controller/Providers/DirectoryService.cs index 5c92069b4..291a26883 100644 --- a/MediaBrowser.Controller/Providers/DirectoryService.cs +++ b/MediaBrowser.Controller/Providers/DirectoryService.cs @@ -43,18 +43,17 @@ namespace MediaBrowser.Controller.Providers return list; } - public FileSystemMetadata GetFile(string path) + public FileSystemMetadata? GetFile(string path) { - var result = _fileCache.GetOrAdd(path, p => + if (!_fileCache.TryGetValue(path, out var result)) { - var file = _fileSystem.GetFileInfo(p); - return file != null && file.Exists ? file : null; - }); - - if (result == null) - { - // lets not store null results in the cache - _fileCache.TryRemove(path, out _); + var file = _fileSystem.GetFileInfo(path); + var res = file != null && file.Exists ? file : null; + if (res != null) + { + result = res; + _fileCache.TryAdd(path, result); + } } return result; |
