diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2026-09-06 08:38:43 +0200 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2026-09-06 08:38:43 +0200 |
| commit | 344a6dcd2c39c6a0a1f34b888f260e297781a2c5 (patch) | |
| tree | 56e566a1c469d4ed7c0ff8acdff215863baf1093 /MediaBrowser.Controller | |
| parent | f8470630be0f3fa7b8052ebd822f23531d30da2f (diff) | |
Apply review suggestions
Diffstat (limited to 'MediaBrowser.Controller')
| -rw-r--r-- | MediaBrowser.Controller/Providers/DirectoryService.cs | 18 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Providers/IDirectoryService.cs | 7 |
2 files changed, 20 insertions, 5 deletions
diff --git a/MediaBrowser.Controller/Providers/DirectoryService.cs b/MediaBrowser.Controller/Providers/DirectoryService.cs index 38872d3cbe..f8e0bf4ed9 100644 --- a/MediaBrowser.Controller/Providers/DirectoryService.cs +++ b/MediaBrowser.Controller/Providers/DirectoryService.cs @@ -170,6 +170,14 @@ namespace MediaBrowser.Controller.Providers } } + public void Move(string source, string destination) + { + Directory.Move(source, destination); + + Invalidate(source); + Invalidate(destination); + } + public bool IsAccessible(string path) { return _fileSystem.GetFileSystemEntryPaths(path).Any(); @@ -178,21 +186,21 @@ namespace MediaBrowser.Controller.Providers private void DropCacheIfIdleOrFull() { var nowMs = Environment.TickCount64; - var idleMs = nowMs - Volatile.Read(ref _lastAccess); + var idleMs = nowMs - _lastAccess; - if (idleMs >= IdleTimeoutMs || Volatile.Read(ref _recordCount) >= MaxCachedRecords) + if (idleMs >= IdleTimeoutMs || _recordCount >= MaxCachedRecords) { _cache.Clear(); _fileCache.Clear(); _filePathCache.Clear(); - Volatile.Write(ref _recordCount, 0); - Volatile.Write(ref _lastAccess, nowMs); + _recordCount = 0; + _lastAccess = nowMs; return; } if (idleMs >= AccessIntervalMs) { - Volatile.Write(ref _lastAccess, nowMs); + _lastAccess = nowMs; } } diff --git a/MediaBrowser.Controller/Providers/IDirectoryService.cs b/MediaBrowser.Controller/Providers/IDirectoryService.cs index 609d094254..3a943d5f0c 100644 --- a/MediaBrowser.Controller/Providers/IDirectoryService.cs +++ b/MediaBrowser.Controller/Providers/IDirectoryService.cs @@ -29,6 +29,13 @@ namespace MediaBrowser.Controller.Providers /// <param name="path">The file or directory path that changed.</param> void Invalidate(string path); + /// <summary> + /// Moves a directory and forgets what is cached about both paths. + /// </summary> + /// <param name="source">The directory to move.</param> + /// <param name="destination">The path to move the directory to.</param> + void Move(string source, string destination); + bool IsAccessible(string path); } } |
