IgnorePatterns.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System.Linq;
  2. using DotNet.Globbing;
  3. namespace Emby.Server.Implementations.Library
  4. {
  5. /// <summary>
  6. /// Glob patterns for files to ignore
  7. /// </summary>
  8. public static class IgnorePatterns
  9. {
  10. /// <summary>
  11. /// Files matching these glob patterns will be ignored
  12. /// </summary>
  13. public static readonly string[] Patterns = new string[]
  14. {
  15. "**/small.jpg",
  16. "**/albumart.jpg",
  17. "**/*sample*",
  18. // Directories
  19. "**/metadata/**",
  20. "**/ps3_update/**",
  21. "**/ps3_vprm/**",
  22. "**/extrafanart/**",
  23. "**/extrathumbs/**",
  24. "**/.actors/**",
  25. "**/.wd_tv/**",
  26. // WMC temp recording directories that will constantly be written to
  27. "**/TempRec/**",
  28. "**/TempSBE/**",
  29. // Synology
  30. "**/eaDir/**",
  31. "**/@eaDir/**",
  32. "**/#recycle/**",
  33. // Qnap
  34. "**/@Recycle/**",
  35. "**/.@__thumb/**",
  36. "**/$RECYCLE.BIN/**",
  37. "**/System Volume Information/**",
  38. "**/.grab/**",
  39. // Unix hidden files and directories
  40. "**/.*/**",
  41. // thumbs.db
  42. "**/thumbs.db",
  43. // bts sync files
  44. "**/*.bts",
  45. "**/*.sync",
  46. };
  47. private static readonly GlobOptions _globOptions = new GlobOptions
  48. {
  49. Evaluation = {
  50. CaseInsensitive = true
  51. }
  52. };
  53. private static readonly Glob[] _globs = Patterns.Select(p => Glob.Parse(p, _globOptions)).ToArray();
  54. /// <summary>
  55. /// Returns true if the supplied path should be ignored
  56. /// </summary>
  57. public static bool ShouldIgnore(string path)
  58. {
  59. return _globs.Any(g => g.IsMatch(path));
  60. }
  61. }
  62. }