diff options
| author | Niels van Velzen <nielsvanvelzen@users.noreply.github.com> | 2025-03-28 07:21:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-28 07:21:59 +0100 |
| commit | 7f5cc544df40bc79bf84c9adcdca35ea224c9c33 (patch) | |
| tree | da5aa2a6a96b96123723c23406470fee9df36d2a /MediaBrowser.Controller/Providers/DirectoryService.cs | |
| parent | f02190c394ad300c00dec4cc4f3b9d42ac6aaca2 (diff) | |
| parent | 15465afd8e7f8a72dd79654f458f8c298e776e02 (diff) | |
Merge pull request #13790 from crobibero/fix-build
Fix build and tests
Diffstat (limited to 'MediaBrowser.Controller/Providers/DirectoryService.cs')
| -rw-r--r-- | MediaBrowser.Controller/Providers/DirectoryService.cs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/MediaBrowser.Controller/Providers/DirectoryService.cs b/MediaBrowser.Controller/Providers/DirectoryService.cs index 4fca94477..a1edfa3c9 100644 --- a/MediaBrowser.Controller/Providers/DirectoryService.cs +++ b/MediaBrowser.Controller/Providers/DirectoryService.cs @@ -1,19 +1,21 @@ #pragma warning disable CS1591 using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; -using BitFaster.Caching.Lru; using MediaBrowser.Model.IO; namespace MediaBrowser.Controller.Providers { public class DirectoryService : IDirectoryService { - // These caches are primarily used for scanning so no reason to have them be large. - private static readonly FastConcurrentLru<string, FileSystemMetadata[]> _cache = new(Environment.ProcessorCount, Math.Max(128, Environment.ProcessorCount * 10), StringComparer.Ordinal); - private static readonly FastConcurrentLru<string, FileSystemMetadata> _fileCache = new(Environment.ProcessorCount, Math.Max(128, Environment.ProcessorCount * 10), StringComparer.Ordinal); - private static readonly FastConcurrentLru<string, List<string>> _filePathCache = new(Environment.ProcessorCount, Math.Max(128, Environment.ProcessorCount * 10), StringComparer.Ordinal); + // TODO make static and switch to FastConcurrentLru. + private readonly ConcurrentDictionary<string, FileSystemMetadata[]> _cache = new(StringComparer.Ordinal); + + private readonly ConcurrentDictionary<string, FileSystemMetadata> _fileCache = new(StringComparer.Ordinal); + + private readonly ConcurrentDictionary<string, List<string>> _filePathCache = new(StringComparer.Ordinal); private readonly IFileSystem _fileSystem; @@ -73,13 +75,13 @@ namespace MediaBrowser.Controller.Providers public FileSystemMetadata? GetFileSystemEntry(string path) { - if (!_fileCache.TryGet(path, out var result)) + if (!_fileCache.TryGetValue(path, out var result)) { var file = _fileSystem.GetFileSystemInfo(path); if (file?.Exists ?? false) { result = file; - _fileCache.AddOrUpdate(path, result); + _fileCache.TryAdd(path, result); } } |
