aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/IgnorePatterns.cs
diff options
context:
space:
mode:
authorVasily <JustAMan@users.noreply.github.com>2020-05-18 22:23:40 +0300
committerGitHub <noreply@github.com>2020-05-18 22:23:40 +0300
commit2d2c1d94733a1959f84c1cc26f8051d0be35cfb4 (patch)
treecfcf6ffaa8520b6ccc225ae5d3898651d1a5efe3 /Emby.Server.Implementations/Library/IgnorePatterns.cs
parente14c85555c6e906175a77c96e96180baf95964a5 (diff)
parentf144acdc9614bed64d7f8842356293a94a3b754a (diff)
Merge pull request #3099 from rigtorp/ignore-patterns
Use glob patterns to ignore files
Diffstat (limited to 'Emby.Server.Implementations/Library/IgnorePatterns.cs')
-rw-r--r--Emby.Server.Implementations/Library/IgnorePatterns.cs73
1 files changed, 73 insertions, 0 deletions
diff --git a/Emby.Server.Implementations/Library/IgnorePatterns.cs b/Emby.Server.Implementations/Library/IgnorePatterns.cs
new file mode 100644
index 000000000..49a36495a
--- /dev/null
+++ b/Emby.Server.Implementations/Library/IgnorePatterns.cs
@@ -0,0 +1,73 @@
+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/**",
+
+ // 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));
+ }
+ }
+}