2020-05-12 21:33:06 +00:00
|
|
|
using System.Linq;
|
|
|
|
using DotNet.Globbing;
|
|
|
|
|
|
|
|
namespace Emby.Server.Implementations.Library
|
|
|
|
{
|
|
|
|
/// <summary>
|
2020-06-15 22:37:52 +00:00
|
|
|
/// Glob patterns for files to ignore.
|
2020-05-12 21:33:06 +00:00
|
|
|
/// </summary>
|
|
|
|
public static class IgnorePatterns
|
|
|
|
{
|
|
|
|
/// <summary>
|
2020-06-15 22:37:52 +00:00
|
|
|
/// Files matching these glob patterns will be ignored.
|
2020-05-12 21:33:06 +00:00
|
|
|
/// </summary>
|
|
|
|
public static readonly string[] Patterns = new string[]
|
|
|
|
{
|
|
|
|
"**/small.jpg",
|
|
|
|
"**/albumart.jpg",
|
|
|
|
"**/*sample*",
|
|
|
|
|
|
|
|
// Directories
|
|
|
|
"**/metadata/**",
|
|
|
|
"**/ps3_update/**",
|
|
|
|
"**/ps3_vprm/**",
|
|
|
|
"**/extrafanart/**",
|
|
|
|
"**/extrathumbs/**",
|
|
|
|
"**/.actors/**",
|
|
|
|
"**/.wd_tv/**",
|
2020-05-20 01:45:48 +00:00
|
|
|
"**/lost+found/**",
|
2020-05-12 21:33:06 +00:00
|
|
|
|
|
|
|
// 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>
|
2020-06-15 22:37:52 +00:00
|
|
|
/// Returns true if the supplied path should be ignored.
|
2020-05-12 21:33:06 +00:00
|
|
|
/// </summary>
|
|
|
|
public static bool ShouldIgnore(string path)
|
|
|
|
{
|
|
|
|
return _globs.Any(g => g.IsMatch(path));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|