Merge pull request #3456 from crobibero/ignore-patterns
Add more ignorepatterns and tests
This commit is contained in:
commit
71cbd51663
|
@ -11,7 +11,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Files matching these glob patterns will be ignored.
|
/// Files matching these glob patterns will be ignored.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly string[] Patterns = new string[]
|
private static readonly string[] _patterns =
|
||||||
{
|
{
|
||||||
"**/small.jpg",
|
"**/small.jpg",
|
||||||
"**/albumart.jpg",
|
"**/albumart.jpg",
|
||||||
|
@ -19,32 +19,51 @@ namespace Emby.Server.Implementations.Library
|
||||||
|
|
||||||
// Directories
|
// Directories
|
||||||
"**/metadata/**",
|
"**/metadata/**",
|
||||||
|
"**/metadata",
|
||||||
"**/ps3_update/**",
|
"**/ps3_update/**",
|
||||||
|
"**/ps3_update",
|
||||||
"**/ps3_vprm/**",
|
"**/ps3_vprm/**",
|
||||||
|
"**/ps3_vprm",
|
||||||
"**/extrafanart/**",
|
"**/extrafanart/**",
|
||||||
|
"**/extrafanart",
|
||||||
"**/extrathumbs/**",
|
"**/extrathumbs/**",
|
||||||
|
"**/extrathumbs",
|
||||||
"**/.actors/**",
|
"**/.actors/**",
|
||||||
|
"**/.actors",
|
||||||
"**/.wd_tv/**",
|
"**/.wd_tv/**",
|
||||||
|
"**/.wd_tv",
|
||||||
"**/lost+found/**",
|
"**/lost+found/**",
|
||||||
|
"**/lost+found",
|
||||||
|
|
||||||
// WMC temp recording directories that will constantly be written to
|
// WMC temp recording directories that will constantly be written to
|
||||||
"**/TempRec/**",
|
"**/TempRec/**",
|
||||||
|
"**/TempRec",
|
||||||
"**/TempSBE/**",
|
"**/TempSBE/**",
|
||||||
|
"**/TempSBE",
|
||||||
|
|
||||||
// Synology
|
// Synology
|
||||||
"**/eaDir/**",
|
"**/eaDir/**",
|
||||||
|
"**/eaDir",
|
||||||
"**/@eaDir/**",
|
"**/@eaDir/**",
|
||||||
|
"**/@eaDir",
|
||||||
"**/#recycle/**",
|
"**/#recycle/**",
|
||||||
|
"**/#recycle",
|
||||||
|
|
||||||
// Qnap
|
// Qnap
|
||||||
"**/@Recycle/**",
|
"**/@Recycle/**",
|
||||||
|
"**/@Recycle",
|
||||||
"**/.@__thumb/**",
|
"**/.@__thumb/**",
|
||||||
|
"**/.@__thumb",
|
||||||
"**/$RECYCLE.BIN/**",
|
"**/$RECYCLE.BIN/**",
|
||||||
|
"**/$RECYCLE.BIN",
|
||||||
"**/System Volume Information/**",
|
"**/System Volume Information/**",
|
||||||
|
"**/System Volume Information",
|
||||||
"**/.grab/**",
|
"**/.grab/**",
|
||||||
|
"**/.grab",
|
||||||
|
|
||||||
// Unix hidden files and directories
|
// Unix hidden files and directories
|
||||||
"**/.*/**",
|
"**/.*/**",
|
||||||
|
"**/.*",
|
||||||
|
|
||||||
// thumbs.db
|
// thumbs.db
|
||||||
"**/thumbs.db",
|
"**/thumbs.db",
|
||||||
|
@ -56,16 +75,19 @@ namespace Emby.Server.Implementations.Library
|
||||||
|
|
||||||
private static readonly GlobOptions _globOptions = new GlobOptions
|
private static readonly GlobOptions _globOptions = new GlobOptions
|
||||||
{
|
{
|
||||||
Evaluation = {
|
Evaluation =
|
||||||
|
{
|
||||||
CaseInsensitive = true
|
CaseInsensitive = true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly Glob[] _globs = Patterns.Select(p => Glob.Parse(p, _globOptions)).ToArray();
|
private static readonly Glob[] _globs = _patterns.Select(p => Glob.Parse(p, _globOptions)).ToArray();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns true if the supplied path should be ignored.
|
/// Returns true if the supplied path should be ignored.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="path">The path to test.</param>
|
||||||
|
/// <returns>Whether to ignore the path.</returns>
|
||||||
public static bool ShouldIgnore(string path)
|
public static bool ShouldIgnore(string path)
|
||||||
{
|
{
|
||||||
return _globs.Any(g => g.IsMatch(path));
|
return _globs.Any(g => g.IsMatch(path));
|
||||||
|
|
|
@ -7,12 +7,19 @@ namespace Jellyfin.Server.Implementations.Tests.Library
|
||||||
{
|
{
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("/media/small.jpg", true)]
|
[InlineData("/media/small.jpg", true)]
|
||||||
|
[InlineData("/media/albumart.jpg", true)]
|
||||||
|
[InlineData("/media/movie.sample.mp4", true)]
|
||||||
[InlineData("/media/movies/#Recycle/test.txt", true)]
|
[InlineData("/media/movies/#Recycle/test.txt", true)]
|
||||||
[InlineData("/media/movies/#recycle/", true)]
|
[InlineData("/media/movies/#recycle/", true)]
|
||||||
|
[InlineData("/media/movies/#recycle", true)]
|
||||||
[InlineData("thumbs.db", true)]
|
[InlineData("thumbs.db", true)]
|
||||||
[InlineData(@"C:\media\movies\movie.avi", false)]
|
[InlineData(@"C:\media\movies\movie.avi", false)]
|
||||||
[InlineData("/media/.hiddendir/file.mp4", true)]
|
[InlineData("/media/.hiddendir/file.mp4", true)]
|
||||||
[InlineData("/media/dir/.hiddenfile.mp4", true)]
|
[InlineData("/media/dir/.hiddenfile.mp4", true)]
|
||||||
|
[InlineData("/volume1/video/Series/@eaDir", true)]
|
||||||
|
[InlineData("/volume1/video/Series/@eaDir/file.txt", true)]
|
||||||
|
[InlineData("/directory/@Recycle", true)]
|
||||||
|
[InlineData("/directory/@Recycle/file.mp3", true)]
|
||||||
public void PathIgnored(string path, bool expected)
|
public void PathIgnored(string path, bool expected)
|
||||||
{
|
{
|
||||||
Assert.Equal(expected, IgnorePatterns.ShouldIgnore(path));
|
Assert.Equal(expected, IgnorePatterns.ShouldIgnore(path));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user