< 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: 101
Uncovered lines: 0
Coverable lines: 101
Total lines: 132
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            "**/subs/**",
 152            "**/subs",
 153
 154            // Trickplay files
 155            "**/*.trickplay",
 156            "**/*.trickplay/**",
 157
 158            // WMC temp recording directories that will constantly be written to
 159            "**/TempRec/**",
 160            "**/TempRec",
 161            "**/TempSBE/**",
 162            "**/TempSBE",
 163
 164            // Synology
 165            "**/eaDir/**",
 166            "**/eaDir",
 167            "**/@eaDir/**",
 168            "**/@eaDir",
 169            "**/#recycle/**",
 170            "**/#recycle",
 171
 172            // Qnap
 173            "**/@Recycle/**",
 174            "**/@Recycle",
 175            "**/.@__thumb/**",
 176            "**/.@__thumb",
 177            "**/$RECYCLE.BIN/**",
 178            "**/$RECYCLE.BIN",
 179            "**/System Volume Information/**",
 180            "**/System Volume Information",
 181            "**/.grab/**",
 182            "**/.grab",
 183
 184            // Unix hidden files
 185            "**/.*",
 186
 187            // Mac - if you ever remove the above.
 188            // "**/._*",
 189            // "**/.DS_Store",
 190
 191            // thumbs.db
 192            "**/thumbs.db",
 193
 194            // bts sync files
 195            "**/*.bts",
 196            "**/*.sync",
 197
 198            // zfs
 199            "**/.zfs/**",
 1100            "**/.zfs"
 1101        };
 102
 1103        private static readonly GlobOptions _globOptions = new GlobOptions
 1104        {
 1105            Evaluation =
 1106            {
 1107                CaseInsensitive = true
 1108            }
 1109        };
 110
 1111        private static readonly Glob[] _globs = Array.ConvertAll(_patterns, p => Glob.Parse(p, _globOptions));
 112
 113        /// <summary>
 114        /// Returns true if the supplied path should be ignored.
 115        /// </summary>
 116        /// <param name="path">The path to test.</param>
 117        /// <returns>Whether to ignore the path.</returns>
 118        public static bool ShouldIgnore(ReadOnlySpan<char> path)
 119        {
 37120            int len = _globs.Length;
 3446121            for (int i = 0; i < len; i++)
 122            {
 1705123                if (_globs[i].IsMatch(path))
 124                {
 19125                    return true;
 126                }
 127            }
 128
 18129            return false;
 130        }
 131    }
 132}