jellyfin/Emby.Server.Implementations/Library/IgnorePatterns.cs

97 lines
2.5 KiB
C#
Raw Normal View History

2020-05-12 23:33:06 +02:00
using System.Linq;
using DotNet.Globbing;
namespace Emby.Server.Implementations.Library
{
/// <summary>
/// Glob patterns for files to ignore.
2020-05-12 23:33:06 +02:00
/// </summary>
public static class IgnorePatterns
{
/// <summary>
/// Files matching these glob patterns will be ignored.
2020-05-12 23:33:06 +02:00
/// </summary>
2020-06-26 19:04:35 +02:00
private static readonly string[] _patterns =
2020-05-12 23:33:06 +02:00
{
"**/small.jpg",
"**/albumart.jpg",
"**/*sample*",
// Directories
"**/metadata/**",
2020-06-26 19:04:35 +02:00
"**/metadata",
2020-05-12 23:33:06 +02:00
"**/ps3_update/**",
2020-06-26 19:04:35 +02:00
"**/ps3_update",
2020-05-12 23:33:06 +02:00
"**/ps3_vprm/**",
2020-06-26 19:04:35 +02:00
"**/ps3_vprm",
2020-05-12 23:33:06 +02:00
"**/extrafanart/**",
2020-06-26 19:04:35 +02:00
"**/extrafanart",
2020-05-12 23:33:06 +02:00
"**/extrathumbs/**",
2020-06-26 19:04:35 +02:00
"**/extrathumbs",
2020-05-12 23:33:06 +02:00
"**/.actors/**",
2020-06-26 19:04:35 +02:00
"**/.actors",
2020-05-12 23:33:06 +02:00
"**/.wd_tv/**",
2020-06-26 19:04:35 +02:00
"**/.wd_tv",
"**/lost+found/**",
2020-06-26 19:04:35 +02:00
"**/lost+found",
2020-05-12 23:33:06 +02:00
// WMC temp recording directories that will constantly be written to
"**/TempRec/**",
2020-06-26 19:04:35 +02:00
"**/TempRec",
2020-05-12 23:33:06 +02:00
"**/TempSBE/**",
2020-06-26 19:04:35 +02:00
"**/TempSBE",
2020-05-12 23:33:06 +02:00
// Synology
"**/eaDir/**",
2020-06-26 19:04:35 +02:00
"**/eaDir",
2020-05-12 23:33:06 +02:00
"**/@eaDir/**",
2020-06-26 19:04:35 +02:00
"**/@eaDir",
2020-05-12 23:33:06 +02:00
"**/#recycle/**",
2020-06-26 19:04:35 +02:00
"**/#recycle",
2020-05-12 23:33:06 +02:00
// Qnap
"**/@Recycle/**",
2020-06-26 19:04:35 +02:00
"**/@Recycle",
2020-05-12 23:33:06 +02:00
"**/.@__thumb/**",
2020-06-26 19:04:35 +02:00
"**/.@__thumb",
2020-05-12 23:33:06 +02:00
"**/$RECYCLE.BIN/**",
2020-06-26 19:04:35 +02:00
"**/$RECYCLE.BIN",
2020-05-12 23:33:06 +02:00
"**/System Volume Information/**",
2020-06-26 19:04:35 +02:00
"**/System Volume Information",
2020-05-12 23:33:06 +02:00
"**/.grab/**",
2020-06-26 19:04:35 +02:00
"**/.grab",
2020-05-12 23:33:06 +02:00
// Unix hidden files and directories
"**/.*/**",
2020-06-26 19:04:35 +02:00
"**/.*",
2020-05-12 23:33:06 +02:00
// thumbs.db
"**/thumbs.db",
// bts sync files
"**/*.bts",
"**/*.sync",
};
private static readonly GlobOptions _globOptions = new GlobOptions
{
2020-06-26 19:04:35 +02:00
Evaluation =
{
2020-05-12 23:33:06 +02:00
CaseInsensitive = true
}
};
2020-06-26 19:04:35 +02:00
private static readonly Glob[] _globs = _patterns.Select(p => Glob.Parse(p, _globOptions)).ToArray();
2020-05-12 23:33:06 +02:00
/// <summary>
/// Returns true if the supplied path should be ignored.
2020-05-12 23:33:06 +02:00
/// </summary>
2020-06-26 19:04:35 +02:00
/// <param name="path">The path to test.</param>
/// <returns>Whether to ignore the path.</returns>
2020-05-12 23:33:06 +02:00
public static bool ShouldIgnore(string path)
{
return _globs.Any(g => g.IsMatch(path));
}
}
}