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 | |
| parent | f8470630be0f3fa7b8052ebd822f23531d30da2f (diff) | |
Apply review suggestions
7 files changed, 22 insertions, 18 deletions
diff --git a/Emby.Server.Implementations/IO/LibraryMonitor.cs b/Emby.Server.Implementations/IO/LibraryMonitor.cs index d5735aed27..0f92e2f03e 100644 --- a/Emby.Server.Implementations/IO/LibraryMonitor.cs +++ b/Emby.Server.Implementations/IO/LibraryMonitor.cs @@ -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 diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 80e89b4305..dc76e1183e 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -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 diff --git a/Jellyfin.Api/Controllers/LibraryStructureController.cs b/Jellyfin.Api/Controllers/LibraryStructureController.cs index e4833c77dd..65bfe25d21 100644 --- a/Jellyfin.Api/Controllers/LibraryStructureController.cs +++ b/Jellyfin.Api/Controllers/LibraryStructureController.cs @@ -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 { 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); } } diff --git a/MediaBrowser.Providers/Lyric/LyricManager.cs b/MediaBrowser.Providers/Lyric/LyricManager.cs index dfa7bfde2f..a19262c3a7 100644 --- a/MediaBrowser.Providers/Lyric/LyricManager.cs +++ b/MediaBrowser.Providers/Lyric/LyricManager.cs @@ -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; diff --git a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs index aa363c425f..cd9dda21a0 100644 --- a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs +++ b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs @@ -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); |
