Apply review suggestions

This commit is contained in:
Shadowghost
2026-09-06 08:38:43 +02:00
parent f8470630be
commit 344a6dcd2c
7 changed files with 22 additions and 18 deletions
@@ -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;
}
}
@@ -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);
}
}