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