< Summary - Jellyfin

Information
Class: Emby.Server.Implementations.Library.Resolvers.SpecialFolderResolver
Assembly: Emby.Server.Implementations
File(s): /srv/git/jellyfin/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs
Line coverage
100%
Covered lines: 33
Uncovered lines: 0
Coverable lines: 33
Total lines: 86
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 5/12/2026 - 12:15:57 AM Line coverage: 100% (33/33) Branch coverage: 100% (8/8) Total lines: 86 5/12/2026 - 12:15:57 AM Line coverage: 100% (33/33) Branch coverage: 100% (8/8) Total lines: 86

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Priority()100%11100%
Resolve(...)100%88100%
GetCollectionType(...)100%11100%

File(s)

/srv/git/jellyfin/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs

#LineLine coverage
 1#nullable disable
 2
 3#pragma warning disable CS1591
 4
 5using System;
 6using System.IO;
 7using System.Linq;
 8using Jellyfin.Data.Enums;
 9using MediaBrowser.Controller;
 10using MediaBrowser.Controller.Entities;
 11using MediaBrowser.Controller.Library;
 12using MediaBrowser.Controller.Resolvers;
 13using MediaBrowser.Model.IO;
 14
 15namespace Emby.Server.Implementations.Library.Resolvers
 16{
 17    public class SpecialFolderResolver : GenericFolderResolver<Folder>
 18    {
 19        private readonly IFileSystem _fileSystem;
 20        private readonly IServerApplicationPaths _appPaths;
 21
 2722        public SpecialFolderResolver(IFileSystem fileSystem, IServerApplicationPaths appPaths)
 23        {
 2724            _fileSystem = fileSystem;
 2725            _appPaths = appPaths;
 2726        }
 27
 28        /// <summary>
 29        /// Gets the priority.
 30        /// </summary>
 31        /// <value>The priority.</value>
 2732        public override ResolverPriority Priority => ResolverPriority.First;
 33
 34        /// <summary>
 35        /// Resolves the specified args.
 36        /// </summary>
 37        /// <param name="args">The args.</param>
 38        /// <returns>Folder.</returns>
 39        protected override Folder Resolve(ItemResolveArgs args)
 40        {
 10341            if (args.IsDirectory)
 42            {
 7343                if (args.IsPhysicalRoot)
 44                {
 2745                    return new AggregateFolder();
 46                }
 47
 4648                if (string.Equals(args.Path, _appPaths.DefaultUserViewsPath, StringComparison.OrdinalIgnoreCase))
 49                {
 2750                    return new UserRootFolder();  // if we got here and still a root - must be user root
 51                }
 52
 1953                if (args.IsVf)
 54                {
 1955                    return new CollectionFolder
 1956                    {
 1957                        CollectionType = GetCollectionType(args),
 1958                        PhysicalLocationsList = args.PhysicalLocations
 1959                    };
 60                }
 61            }
 62
 3063            return null;
 64        }
 65
 66        private CollectionType? GetCollectionType(ItemResolveArgs args)
 67        {
 1968            return args.FileSystemChildren
 1969                .Where(i =>
 1970                {
 1971                    try
 1972                    {
 1973                        return !i.IsDirectory &&
 1974                               string.Equals(".collection", i.Extension, StringComparison.OrdinalIgnoreCase);
 1975                    }
 1976                    catch (IOException)
 1977                    {
 1978                        return false;
 1979                    }
 1980                })
 1981                .Select(i => _fileSystem.GetFileNameWithoutExtension(i))
 1982                .Select(i => Enum.TryParse<CollectionType>(i, out var collectionType) ? collectionType : (CollectionType
 1983                .FirstOrDefault(i => i is not null);
 84        }
 85    }
 86}