IgnorePatterns.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. "**/lost+found/**",
  27. // WMC temp recording directories that will constantly be written to
  28. "**/TempRec/**",
  29. "**/TempSBE/**",
  30. // Synology
  31. "**/eaDir/**",
  32. "**/@eaDir/**",
  33. "**/#recycle/**",
  34. // Qnap
  35. "**/@Recycle/**",
  36. "**/.@__thumb/**",
  37. "**/$RECYCLE.BIN/**",
  38. "**/System Volume Information/**",
  39. "**/.grab/**",
  40. // Unix hidden files and directories
  41. "**/.*/**",
  42. // thumbs.db
  43. "**/thumbs.db",
  44. // bts sync files
  45. "**/*.bts",
  46. "**/*.sync",
  47. };
  48. private static readonly GlobOptions _globOptions = new GlobOptions
  49. {
  50. Evaluation = {
  51. CaseInsensitive = true
  52. }
  53. };
  54. private static readonly Glob[] _globs = Patterns.Select(p => Glob.Parse(p, _globOptions)).ToArray();
  55. /// <summary>
  56. /// Returns true if the supplied path should be ignored.
  57. /// </summary>
  58. public static bool ShouldIgnore(string path)
  59. {
  60. return _globs.Any(g => g.IsMatch(path));
  61. }
  62. }
  63. }