< Summary - Jellyfin

Information
Class: Emby.Server.Implementations.Library.IgnorePatterns
Assembly: Emby.Server.Implementations
File(s): /srv/git/jellyfin/Emby.Server.Implementations/Library/IgnorePatterns.cs
Line coverage
100%
Covered lines: 99
Uncovered lines: 0
Coverable lines: 99
Total lines: 131
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
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
.cctor()100%11100%
ShouldIgnore(...)100%44100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Linq;
 3using DotNet.Globbing;
 4
 5namespace Emby.Server.Implementations.Library
 6{
 7    /// <summary>
 8    /// Glob patterns for files to ignore.
 9    /// </summary>
 10    public static class IgnorePatterns
 11    {
 12        /// <summary>
 13        /// Files matching these glob patterns will be ignored.
 14        /// </summary>
 115        private static readonly string[] _patterns =
 116        {
 117            "**/small.jpg",
 118            "**/albumart.jpg",
 119
 120            // We have neither non-greedy matching or character group repetitions, working around that here.
 121            // https://github.com/dazinator/DotNet.Glob#patterns
 122            // .*/sample\..{1,5}
 123            "**/sample.?",
 124            "**/sample.??",
 125            "**/sample.???", // Matches sample.mkv
 126            "**/sample.????", // Matches sample.webm
 127            "**/sample.?????",
 128            "**/*.sample.?",
 129            "**/*.sample.??",
 130            "**/*.sample.???",
 131            "**/*.sample.????",
 132            "**/*.sample.?????",
 133            "**/sample/*",
 134
 135            // Directories
 136            "**/metadata/**",
 137            "**/metadata",
 138            "**/ps3_update/**",
 139            "**/ps3_update",
 140            "**/ps3_vprm/**",
 141            "**/ps3_vprm",
 142            "**/extrafanart/**",
 143            "**/extrafanart",
 144            "**/extrathumbs/**",
 145            "**/extrathumbs",
 146            "**/.actors/**",
 147            "**/.actors",
 148            "**/.wd_tv/**",
 149            "**/.wd_tv",
 150            "**/lost+found/**",
 151            "**/lost+found",
 152
 153            // Trickplay files
 154            "**/*.trickplay",
 155            "**/*.trickplay/**",
 156
 157            // WMC temp recording directories that will constantly be written to
 158            "**/TempRec/**",
 159            "**/TempRec",
 160            "**/TempSBE/**",
 161            "**/TempSBE",
 162
 163            // Synology
 164            "**/eaDir/**",
 165            "**/eaDir",
 166            "**/@eaDir/**",
 167            "**/@eaDir",
 168            "**/#recycle/**",
 169            "**/#recycle",
 170
 171            // Qnap
 172            "**/@Recycle/**",
 173            "**/@Recycle",
 174            "**/.@__thumb/**",
 175            "**/.@__thumb",
 176            "**/$RECYCLE.BIN/**",
 177            "**/$RECYCLE.BIN",
 178            "**/System Volume Information/**",
 179            "**/System Volume Information",
 180            "**/.grab/**",
 181            "**/.grab",
 182
 183            // Unix hidden files
 184            "**/.*",
 185
 186            // Mac - if you ever remove the above.
 187            // "**/._*",
 188            // "**/.DS_Store",
 189
 190            // thumbs.db
 191            "**/thumbs.db",
 192
 193            // bts sync files
 194            "**/*.bts",
 195            "**/*.sync",
 196
 197            // zfs
 198            "**/.zfs/**",
 199            "**/.zfs"
 1100        };
 101
 1102        private static readonly GlobOptions _globOptions = new GlobOptions
 1103        {
 1104            Evaluation =
 1105            {
 1106                CaseInsensitive = true
 1107            }
 1108        };
 109
 1110        private static readonly Glob[] _globs = Array.ConvertAll(_patterns, p => Glob.Parse(p, _globOptions));
 111
 112        /// <summary>
 113        /// Returns true if the supplied path should be ignored.
 114        /// </summary>
 115        /// <param name="path">The path to test.</param>
 116        /// <returns>Whether to ignore the path.</returns>
 117        public static bool ShouldIgnore(ReadOnlySpan<char> path)
 118        {
 26119            int len = _globs.Length;
 2160120            for (int i = 0; i < len; i++)
 121            {
 1072122                if (_globs[i].IsMatch(path))
 123                {
 18124                    return true;
 125                }
 126            }
 127
 8128            return false;
 129        }
 130    }
 131}