aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/IgnorePatterns.cs
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2020-06-13 13:03:09 -0600
committercrobibero <cody@robibe.ro>2020-06-13 13:03:09 -0600
commit829eb1a8494b3d0a4a5170f5942f33920f179e73 (patch)
tree50acc3d0800da593aac0a252dad6226c73f3c1d5 /Emby.Server.Implementations/Library/IgnorePatterns.cs
parentd975ad155e7857bcbfcf55246fd78dd87ed594ca (diff)
parent403cd3205ffb970cfda88b6c49dc69127fada798 (diff)
merge master into api-migration
Diffstat (limited to 'Emby.Server.Implementations/Library/IgnorePatterns.cs')
-rw-r--r--Emby.Server.Implementations/Library/IgnorePatterns.cs74
1 files changed, 74 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..d12b5855b
--- /dev/null
+++ b/Emby.Server.Implementations/Library/IgnorePatterns.cs
@@ -0,0 +1,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));
+ }
+ }
+}