aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/IgnorePatterns.cs
blob: 8c40989489f159adc1304f593cdd136211842b7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System.Linq;
using DotNet.Globbing;

namespace Emby.Server.Implementations.Library
{
    /// <summary>
    /// Glob patterns for files to ignore.
    /// </summary>
    public static class IgnorePatterns
    {
        /// <summary>
        /// Files matching these glob patterns will be ignored.
        /// </summary>
        public static readonly string[] Patterns = new string[]
        {
            "**/small.jpg",
            "**/albumart.jpg",
            "**/*sample*",

            // Directories
            "**/metadata/**",
            "**/ps3_update/**",
            "**/ps3_vprm/**",
            "**/extrafanart/**",
            "**/extrathumbs/**",
            "**/.actors/**",
            "**/.wd_tv/**",
            "**/lost+found/**",

            // WMC temp recording directories that will constantly be written to
            "**/TempRec/**",
            "**/TempSBE/**",

            // Synology
            "**/eaDir/**",
            "**/@eaDir/**",
            "**/#recycle/**",

            // Qnap
            "**/@Recycle/**",
            "**/.@__thumb/**",
            "**/$RECYCLE.BIN/**",
            "**/System Volume Information/**",
            "**/.grab/**",

            // Unix hidden files and directories
            "**/.*/**",

            // thumbs.db
            "**/thumbs.db",

            // bts sync files
            "**/*.bts",
            "**/*.sync",
        };

        private static readonly GlobOptions _globOptions = new GlobOptions
        {
            Evaluation = {
                CaseInsensitive = true
            }
        };

        private static readonly Glob[] _globs = Patterns.Select(p => Glob.Parse(p, _globOptions)).ToArray();

        /// <summary>
        /// Returns true if the supplied path should be ignored.
        /// </summary>
        public static bool ShouldIgnore(string path)
        {
            return _globs.Any(g => g.IsMatch(path));
        }
    }
}