aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/LibraryManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Library/LibraryManager.cs')
-rw-r--r--Emby.Server.Implementations/Library/LibraryManager.cs53
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);