diff options
| author | Cody Robibero <cody@robibe.ro> | 2026-11-20 07:14:33 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-20 07:14:33 -0500 |
| commit | be19e7c7786f62e79ea79a671908986b73e47a61 (patch) | |
| tree | e9941c3e4e95d0803b8b27be03b06094c3e520e2 /Emby.Server.Implementations/Library/LibraryManager.cs | |
| parent | 5c05f2af03642cada0f73a255289c433c88e557c (diff) | |
| parent | 6561d58ad512bdc4dfd6dacf55a5b03b2a143623 (diff) | |
Merge pull request #18275 from Shadowghost/fix/17364-dotignore-library-root
Confine ignore file handling to library root
Diffstat (limited to 'Emby.Server.Implementations/Library/LibraryManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/Library/LibraryManager.cs | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 16616dd328..c877c8bf2c 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<ExtraResolver>(), 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,40 @@ namespace Emby.Server.Implementations.Library return info; } + private IEnumerable<string> 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<string>(); + } + + // Reads the .mblink files directly; going through RootFolder.Children would re-enter the resolver. + private IEnumerable<string> GetLibraryRootPaths() + { + // root/default only exists once the user root folder or a library has been created + var userViewsPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath; + if (!_fileSystem.DirectoryExists(userViewsPath)) + { + return []; + } + + return _fileSystem.GetDirectoryPaths(userViewsPath) + .SelectMany(GetVirtualFolderLocations) + .ToList(); + } + private CollectionTypeOptions? GetCollectionType(string path) { var files = _fileSystem.GetFilePaths(path, [".collection"], true, false); |
