Apply review suggestions
This commit is contained in:
@@ -368,8 +368,6 @@ namespace Emby.Server.Implementations.IO
|
||||
return;
|
||||
}
|
||||
|
||||
// The injected service is a singleton, so drop the path before the checks below:
|
||||
// a change we deliberately do not refresh for still has to read correctly later.
|
||||
_directoryService.Invalidate(path);
|
||||
|
||||
// Ignore certain files, If the parent of an ignored path has a change event, ignore that too
|
||||
|
||||
@@ -3723,7 +3723,6 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
}
|
||||
|
||||
// The injected service is a singleton, so its listing predates this folder.
|
||||
_directoryService.Invalidate(virtualFolderPath);
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -183,15 +183,11 @@ public class LibraryStructureController : BaseJellyfinApiController
|
||||
var tempPath = Path.Combine(
|
||||
rootFolderPath,
|
||||
Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture));
|
||||
Directory.Move(currentPath, tempPath);
|
||||
_directoryService.Move(currentPath, tempPath);
|
||||
currentPath = tempPath;
|
||||
}
|
||||
|
||||
Directory.Move(currentPath, newPath);
|
||||
|
||||
// The injected service is a singleton, so its listings of both paths are now stale.
|
||||
_directoryService.Invalidate(currentPath);
|
||||
_directoryService.Invalidate(newPath);
|
||||
_directoryService.Move(currentPath, newPath);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +255,6 @@ public class LyricManager : ILyricManager
|
||||
_libraryMonitor.ReportFileSystemChangeComplete(path, false);
|
||||
}
|
||||
|
||||
// The injected service is a singleton, so its listing would keep the deleted file.
|
||||
_directoryService.Invalidate(path);
|
||||
}
|
||||
|
||||
@@ -453,7 +452,6 @@ public class LyricManager : ILyricManager
|
||||
await stream.CopyToAsync(fs).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// The injected service is a singleton, so its listing of the folder is now stale.
|
||||
_directoryService.Invalidate(savePath);
|
||||
|
||||
return;
|
||||
|
||||
@@ -284,7 +284,6 @@ namespace MediaBrowser.Providers.Subtitles
|
||||
await stream.CopyToAsync(fs).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// The injected service is a singleton, so its listing of the folder is now stale.
|
||||
_directoryService.Invalidate(path);
|
||||
|
||||
return;
|
||||
@@ -401,7 +400,6 @@ namespace MediaBrowser.Providers.Subtitles
|
||||
_monitor.ReportFileSystemChangeComplete(path, false);
|
||||
}
|
||||
|
||||
// The injected service is a singleton, so its listing would keep the deleted file.
|
||||
_directoryService.Invalidate(path);
|
||||
|
||||
return item.RefreshMetadata(CancellationToken.None);
|
||||
|
||||
Reference in New Issue
Block a user