From d73e3d964e3ce8197ec86bdaad447072305bc0d6 Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Wed, 2 Sep 2026 07:06:08 +0200 Subject: Optimize Caches Co-Authored-By: Cody Robibero --- Jellyfin.Api/Controllers/LibraryStructureController.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Jellyfin.Api/Controllers/LibraryStructureController.cs') diff --git a/Jellyfin.Api/Controllers/LibraryStructureController.cs b/Jellyfin.Api/Controllers/LibraryStructureController.cs index 5c596c21b9..5cd6dada19 100644 --- a/Jellyfin.Api/Controllers/LibraryStructureController.cs +++ b/Jellyfin.Api/Controllers/LibraryStructureController.cs @@ -16,6 +16,7 @@ using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using Microsoft.AspNetCore.Authorization; @@ -34,6 +35,7 @@ public class LibraryStructureController : BaseJellyfinApiController private readonly IServerApplicationPaths _appPaths; private readonly ILibraryManager _libraryManager; private readonly ILibraryMonitor _libraryMonitor; + private readonly IDirectoryService _directoryService; /// /// Initializes a new instance of the class. @@ -41,14 +43,17 @@ public class LibraryStructureController : BaseJellyfinApiController /// Instance of interface. /// Instance of interface. /// Instance of interface. + /// Instance of interface. public LibraryStructureController( IServerConfigurationManager serverConfigurationManager, ILibraryManager libraryManager, - ILibraryMonitor libraryMonitor) + ILibraryMonitor libraryMonitor, + IDirectoryService directoryService) { _appPaths = serverConfigurationManager.ApplicationPaths; _libraryManager = libraryManager; _libraryMonitor = libraryMonitor; + _directoryService = directoryService; } /// @@ -183,6 +188,11 @@ public class LibraryStructureController : BaseJellyfinApiController } Directory.Move(currentPath, newPath); + + // The directory caches are shared, so the validation below would otherwise resolve the + // libraries root from a listing taken before the folder was moved. + _directoryService.Invalidate(currentPath); + _directoryService.Invalidate(newPath); } finally { -- cgit v1.2.3