< Summary - Jellyfin

Information
Class: Emby.Server.Implementations.Library.CoreResolutionIgnoreRule
Assembly: Emby.Server.Implementations
File(s): /srv/git/jellyfin/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
Line coverage
23%
Covered lines: 5
Uncovered lines: 16
Coverable lines: 21
Total lines: 82
Line coverage: 23.8%
Branch coverage
4%
Covered branches: 1
Total branches: 24
Branch coverage: 4.1%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
ShouldIgnore(...)4.16%428.562411.11%

File(s)

/srv/git/jellyfin/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs

#LineLine coverage
 1using System;
 2using System.IO;
 3using Emby.Naming.Audio;
 4using Emby.Naming.Common;
 5using MediaBrowser.Controller;
 6using MediaBrowser.Controller.Entities;
 7using MediaBrowser.Controller.Resolvers;
 8using MediaBrowser.Model.IO;
 9
 10namespace Emby.Server.Implementations.Library
 11{
 12    /// <summary>
 13    /// Provides the core resolver ignore rules.
 14    /// </summary>
 15    public class CoreResolutionIgnoreRule : IResolverIgnoreRule
 16    {
 17        private readonly NamingOptions _namingOptions;
 18        private readonly IServerApplicationPaths _serverApplicationPaths;
 19
 20        /// <summary>
 21        /// Initializes a new instance of the <see cref="CoreResolutionIgnoreRule"/> class.
 22        /// </summary>
 23        /// <param name="namingOptions">The naming options.</param>
 24        /// <param name="serverApplicationPaths">The server application paths.</param>
 25        public CoreResolutionIgnoreRule(NamingOptions namingOptions, IServerApplicationPaths serverApplicationPaths)
 26        {
 2227            _namingOptions = namingOptions;
 2228            _serverApplicationPaths = serverApplicationPaths;
 2229        }
 30
 31        /// <inheritdoc />
 32        public bool ShouldIgnore(FileSystemMetadata fileInfo, BaseItem? parent)
 33        {
 34            // Don't ignore application folders
 5435            if (fileInfo.FullName.Contains(_serverApplicationPaths.RootFolderPath, StringComparison.InvariantCulture))
 36            {
 5437                return false;
 38            }
 39
 40            // Don't ignore top level folders
 041            if (fileInfo.IsDirectory && parent is AggregateFolder)
 42            {
 043                return false;
 44            }
 45
 046            if (IgnorePatterns.ShouldIgnore(fileInfo.FullName))
 47            {
 048                return true;
 49            }
 50
 051            var filename = fileInfo.Name;
 52
 053            if (fileInfo.IsDirectory)
 54            {
 055                if (parent is not null)
 56                {
 57                    // Ignore extras folders but allow it at the collection level
 058                    if (_namingOptions.AllExtrasTypesFolderNames.ContainsKey(filename)
 059                        && parent is not AggregateFolder
 060                        && parent is not UserRootFolder)
 61                    {
 062                        return true;
 63                    }
 64                }
 65            }
 66            else
 67            {
 068                if (parent is not null)
 69                {
 70                    // Don't resolve these into audio files
 071                    if (Path.GetFileNameWithoutExtension(filename.AsSpan()).Equals(BaseItem.ThemeSongFileName, StringCom
 072                        && AudioFileParser.IsAudioFile(filename, _namingOptions))
 73                    {
 074                        return true;
 75                    }
 76                }
 77            }
 78
 079            return false;
 80        }
 81    }
 82}