From d46109aa695ef7ba461c5db774e2a0577ab656b9 Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Fri, 2 Oct 2026 22:48:08 +0200 Subject: Confine ignore file handling to library root --- .../Library/LibraryManager.cs | 46 ++++++++++++++-------- 1 file changed, 29 insertions(+), 17 deletions(-) (limited to 'Emby.Server.Implementations/Library/LibraryManager.cs') diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 16616dd328..6d8e9abc45 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -184,6 +184,7 @@ namespace Emby.Server.Implementations.Library _peopleRepository = peopleRepository; _pathManager = pathManager; _dotIgnoreIgnoreRule = dotIgnoreIgnoreRule; + _dotIgnoreIgnoreRule.SetLibraryRootsProvider(GetLibraryRootPaths); _localization = localization; _directoryService = directoryService; _extraResolver = new ExtraResolver(loggerFactory.CreateLogger(), namingOptions, directoryService); @@ -1627,23 +1628,7 @@ namespace Emby.Server.Implementations.Library { Name = Path.GetFileName(dir), - Locations = _fileSystem.GetFilePaths(dir, false) - .Where(i => Path.GetExtension(i.AsSpan()).Equals(ShortcutFileExtension, StringComparison.OrdinalIgnoreCase)) - .Select(i => - { - try - { - return _appHost.ExpandVirtualPath(_fileSystem.ResolveShortcut(i)); - } - catch (Exception ex) - { - _logger.LogError(ex, "Error resolving shortcut file {File}", i); - return null; - } - }) - .Where(i => i is not null) - .Order() - .ToArray(), + Locations = GetVirtualFolderLocations(dir).Order().ToArray(), CollectionType = GetCollectionType(dir) }; @@ -1671,6 +1656,33 @@ namespace Emby.Server.Implementations.Library return info; } + private IEnumerable GetVirtualFolderLocations(string dir) + { + return _fileSystem.GetFilePaths(dir, false) + .Where(i => Path.GetExtension(i.AsSpan()).Equals(ShortcutFileExtension, StringComparison.OrdinalIgnoreCase)) + .Select(i => + { + try + { + return _appHost.ExpandVirtualPath(_fileSystem.ResolveShortcut(i)); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error resolving shortcut file {File}", i); + return null; + } + }) + .OfType(); + } + + // Reads the .mblink files directly; going through RootFolder.Children would re-enter the resolver. + private IEnumerable GetLibraryRootPaths() + { + return _fileSystem.GetDirectoryPaths(_configurationManager.ApplicationPaths.DefaultUserViewsPath) + .SelectMany(GetVirtualFolderLocations) + .ToList(); + } + private CollectionTypeOptions? GetCollectionType(string path) { var files = _fileSystem.GetFilePaths(path, [".collection"], true, false); -- cgit v1.2.3