From 9018f8d8be10bc4812f7d1bd230a1516eca61eea Mon Sep 17 00:00:00 2001 From: telans Date: Tue, 16 Jun 2020 10:37:52 +1200 Subject: Add full stop at end of comments (SA1629) --- Emby.Server.Implementations/Library/IgnorePatterns.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Emby.Server.Implementations/Library/IgnorePatterns.cs') diff --git a/Emby.Server.Implementations/Library/IgnorePatterns.cs b/Emby.Server.Implementations/Library/IgnorePatterns.cs index d12b5855b..8c4098948 100644 --- a/Emby.Server.Implementations/Library/IgnorePatterns.cs +++ b/Emby.Server.Implementations/Library/IgnorePatterns.cs @@ -4,12 +4,12 @@ using DotNet.Globbing; namespace Emby.Server.Implementations.Library { /// - /// Glob patterns for files to ignore + /// Glob patterns for files to ignore. /// public static class IgnorePatterns { /// - /// Files matching these glob patterns will be ignored + /// Files matching these glob patterns will be ignored. /// public static readonly string[] Patterns = new string[] { @@ -64,7 +64,7 @@ namespace Emby.Server.Implementations.Library private static readonly Glob[] _globs = Patterns.Select(p => Glob.Parse(p, _globOptions)).ToArray(); /// - /// Returns true if the supplied path should be ignored + /// Returns true if the supplied path should be ignored. /// public static bool ShouldIgnore(string path) { -- cgit v1.2.3 From 9772749d8fa2c86089ff1e3e0b8443633193106a Mon Sep 17 00:00:00 2001 From: crobibero Date: Fri, 26 Jun 2020 11:04:35 -0600 Subject: Add more ignorepatterns and tests --- .../Library/IgnorePatterns.cs | 28 +++++++++++++++++++--- .../Library/IgnorePatternsTests.cs | 7 ++++++ 2 files changed, 32 insertions(+), 3 deletions(-) (limited to 'Emby.Server.Implementations/Library/IgnorePatterns.cs') diff --git a/Emby.Server.Implementations/Library/IgnorePatterns.cs b/Emby.Server.Implementations/Library/IgnorePatterns.cs index 8c4098948..cd5c5f19d 100644 --- a/Emby.Server.Implementations/Library/IgnorePatterns.cs +++ b/Emby.Server.Implementations/Library/IgnorePatterns.cs @@ -11,7 +11,7 @@ namespace Emby.Server.Implementations.Library /// /// Files matching these glob patterns will be ignored. /// - public static readonly string[] Patterns = new string[] + private static readonly string[] _patterns = { "**/small.jpg", "**/albumart.jpg", @@ -19,32 +19,51 @@ namespace Emby.Server.Implementations.Library // Directories "**/metadata/**", + "**/metadata", "**/ps3_update/**", + "**/ps3_update", "**/ps3_vprm/**", + "**/ps3_vprm", "**/extrafanart/**", + "**/extrafanart", "**/extrathumbs/**", + "**/extrathumbs", "**/.actors/**", + "**/.actors", "**/.wd_tv/**", + "**/.wd_tv", "**/lost+found/**", + "**/lost+found", // WMC temp recording directories that will constantly be written to "**/TempRec/**", + "**/TempRec", "**/TempSBE/**", + "**/TempSBE", // Synology "**/eaDir/**", + "**/eaDir", "**/@eaDir/**", + "**/@eaDir", "**/#recycle/**", + "**/#recycle", // Qnap "**/@Recycle/**", + "**/@Recycle", "**/.@__thumb/**", + "**/.@__thumb", "**/$RECYCLE.BIN/**", + "**/$RECYCLE.BIN", "**/System Volume Information/**", + "**/System Volume Information", "**/.grab/**", + "**/.grab", // Unix hidden files and directories "**/.*/**", + "**/.*", // thumbs.db "**/thumbs.db", @@ -56,16 +75,19 @@ namespace Emby.Server.Implementations.Library private static readonly GlobOptions _globOptions = new GlobOptions { - Evaluation = { + Evaluation = + { 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(); /// /// Returns true if the supplied path should be ignored. /// + /// The path to test. + /// Whether to ignore the path. public static bool ShouldIgnore(string path) { return _globs.Any(g => g.IsMatch(path)); diff --git a/tests/Jellyfin.Server.Implementations.Tests/Library/IgnorePatternsTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Library/IgnorePatternsTests.cs index 26dee38c6..c145ddc9d 100644 --- a/tests/Jellyfin.Server.Implementations.Tests/Library/IgnorePatternsTests.cs +++ b/tests/Jellyfin.Server.Implementations.Tests/Library/IgnorePatternsTests.cs @@ -7,12 +7,19 @@ namespace Jellyfin.Server.Implementations.Tests.Library { [Theory] [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/", true)] + [InlineData("/media/movies/#recycle", true)] [InlineData("thumbs.db", true)] [InlineData(@"C:\media\movies\movie.avi", false)] [InlineData("/media/.hiddendir/file.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) { Assert.Equal(expected, IgnorePatterns.ShouldIgnore(path)); -- cgit v1.2.3 From cb193b6afd339ab62a76644e02e9459962756c00 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Sat, 27 Jun 2020 11:32:57 +0200 Subject: Add support for ReadOnlySpan in IgnorePatterns --- Emby.Server.Implementations/Library/IgnorePatterns.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'Emby.Server.Implementations/Library/IgnorePatterns.cs') diff --git a/Emby.Server.Implementations/Library/IgnorePatterns.cs b/Emby.Server.Implementations/Library/IgnorePatterns.cs index cd5c5f19d..6e6ef1359 100644 --- a/Emby.Server.Implementations/Library/IgnorePatterns.cs +++ b/Emby.Server.Implementations/Library/IgnorePatterns.cs @@ -1,3 +1,6 @@ +#nullable enable + +using System; using System.Linq; using DotNet.Globbing; @@ -88,9 +91,18 @@ namespace Emby.Server.Implementations.Library /// /// The path to test. /// Whether to ignore the path. - public static bool ShouldIgnore(string path) + public static bool ShouldIgnore(ReadOnlySpan path) { - return _globs.Any(g => g.IsMatch(path)); + int len = _globs.Length; + for (int i = 0; i < len; i++) + { + if (_globs[i].IsMatch(path)) + { + return true; + } + } + + return false; } } } -- cgit v1.2.3 From 11d5410dbb2df9e6c4e5ad5de4cc5db741014c09 Mon Sep 17 00:00:00 2001 From: Odd Stråbø Date: Sat, 25 Jul 2020 23:50:49 +0200 Subject: Don't ignore dot directories. Use `.ignore` file to hide directory from library scan. Also, please tell me we handle sample matching somewhere else? This is a mess. --- Emby.Server.Implementations/Library/IgnorePatterns.cs | 19 ++++++++++++++++--- .../Library/IgnorePatternsTests.cs | 10 +++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'Emby.Server.Implementations/Library/IgnorePatterns.cs') diff --git a/Emby.Server.Implementations/Library/IgnorePatterns.cs b/Emby.Server.Implementations/Library/IgnorePatterns.cs index 6e6ef1359..cb93453ea 100644 --- a/Emby.Server.Implementations/Library/IgnorePatterns.cs +++ b/Emby.Server.Implementations/Library/IgnorePatterns.cs @@ -18,7 +18,17 @@ namespace Emby.Server.Implementations.Library { "**/small.jpg", "**/albumart.jpg", - "**/*sample*", + + // What is this reg ex you speak of? + "**/*.sample.?", + "**/*.sample.??", + "**/*.sample.????", + "**/*.sample.?????", + "**/sample.?", + "**/sample.??", + "**/sample.????", + "**/sample.?????", + "**/sample/*", // Directories "**/metadata/**", @@ -64,10 +74,13 @@ namespace Emby.Server.Implementations.Library "**/.grab/**", "**/.grab", - // Unix hidden files and directories - "**/.*/**", + // Unix hidden files "**/.*", + // Mac - if you ever remove the above. + // "**/._*", + // "**/.DS_Store", + // thumbs.db "**/thumbs.db", diff --git a/tests/Jellyfin.Server.Implementations.Tests/Library/IgnorePatternsTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Library/IgnorePatternsTests.cs index c145ddc9d..e52b40be5 100644 --- a/tests/Jellyfin.Server.Implementations.Tests/Library/IgnorePatternsTests.cs +++ b/tests/Jellyfin.Server.Implementations.Tests/Library/IgnorePatternsTests.cs @@ -9,17 +9,25 @@ namespace Jellyfin.Server.Implementations.Tests.Library [InlineData("/media/small.jpg", true)] [InlineData("/media/albumart.jpg", true)] [InlineData("/media/movie.sample.mp4", true)] + [InlineData("/media/movie/sample.mp4", true)] + [InlineData("/media/movie/sample/movie.mp4", true)] + [InlineData("/foo/sample/bar/baz.mkv", false)] + [InlineData("/media/movies/the sample/the sample.mkv", false)] + [InlineData("/media/movies/sampler.mkv", false)] [InlineData("/media/movies/#Recycle/test.txt", true)] [InlineData("/media/movies/#recycle/", true)] [InlineData("/media/movies/#recycle", true)] [InlineData("thumbs.db", true)] [InlineData(@"C:\media\movies\movie.avi", false)] - [InlineData("/media/.hiddendir/file.mp4", true)] + [InlineData("/media/.hiddendir/file.mp4", false)] [InlineData("/media/dir/.hiddenfile.mp4", true)] + [InlineData("/media/dir/._macjunk.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)] + [InlineData("/media/movies/.@__thumb", true)] + [InlineData("/media/movies/.@__thumb/foo-bar-thumbnail.png", true)] public void PathIgnored(string path, bool expected) { Assert.Equal(expected, IgnorePatterns.ShouldIgnore(path)); -- cgit v1.2.3 From 800260af431fb7cb905993fdc1e3566e43154a39 Mon Sep 17 00:00:00 2001 From: Odd Stråbø Date: Sun, 26 Jul 2020 00:19:24 +0200 Subject: Yep. I failed at copy-pasting. --- Emby.Server.Implementations/Library/IgnorePatterns.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Emby.Server.Implementations/Library/IgnorePatterns.cs') diff --git a/Emby.Server.Implementations/Library/IgnorePatterns.cs b/Emby.Server.Implementations/Library/IgnorePatterns.cs index cb93453ea..62c81e0c7 100644 --- a/Emby.Server.Implementations/Library/IgnorePatterns.cs +++ b/Emby.Server.Implementations/Library/IgnorePatterns.cs @@ -22,10 +22,12 @@ namespace Emby.Server.Implementations.Library // What is this reg ex you speak of? "**/*.sample.?", "**/*.sample.??", + "**/*.sample.???", "**/*.sample.????", "**/*.sample.?????", "**/sample.?", "**/sample.??", + "**/sample.???", "**/sample.????", "**/sample.?????", "**/sample/*", -- cgit v1.2.3 From de708d2fca268eb470b34013f4a52493e34908a1 Mon Sep 17 00:00:00 2001 From: Odd Stråbø Date: Sun, 26 Jul 2020 17:11:43 +0200 Subject: Comment --- Emby.Server.Implementations/Library/IgnorePatterns.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Emby.Server.Implementations/Library/IgnorePatterns.cs') diff --git a/Emby.Server.Implementations/Library/IgnorePatterns.cs b/Emby.Server.Implementations/Library/IgnorePatterns.cs index 62c81e0c7..9ba96818a 100644 --- a/Emby.Server.Implementations/Library/IgnorePatterns.cs +++ b/Emby.Server.Implementations/Library/IgnorePatterns.cs @@ -19,7 +19,7 @@ namespace Emby.Server.Implementations.Library "**/small.jpg", "**/albumart.jpg", - // What is this reg ex you speak of? + // https://github.com/dazinator/DotNet.Glob#patterns "**/*.sample.?", "**/*.sample.??", "**/*.sample.???", -- cgit v1.2.3 From 7fa80ac3e0695eaf279eeef6ac643044f0e399ba Mon Sep 17 00:00:00 2001 From: Odd Stråbø Date: Sun, 26 Jul 2020 23:02:11 +0200 Subject: Add more tests, update comment --- Emby.Server.Implementations/Library/IgnorePatterns.cs | 1 + .../Library/IgnorePatternsTests.cs | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'Emby.Server.Implementations/Library/IgnorePatterns.cs') diff --git a/Emby.Server.Implementations/Library/IgnorePatterns.cs b/Emby.Server.Implementations/Library/IgnorePatterns.cs index 9ba96818a..8a85c852a 100644 --- a/Emby.Server.Implementations/Library/IgnorePatterns.cs +++ b/Emby.Server.Implementations/Library/IgnorePatterns.cs @@ -19,6 +19,7 @@ namespace Emby.Server.Implementations.Library "**/small.jpg", "**/albumart.jpg", + // We have neither non-greedy matching or character group repetitions, working around that here. // https://github.com/dazinator/DotNet.Glob#patterns "**/*.sample.?", "**/*.sample.??", diff --git a/tests/Jellyfin.Server.Implementations.Tests/Library/IgnorePatternsTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Library/IgnorePatternsTests.cs index e52b40be5..b4e6db8f3 100644 --- a/tests/Jellyfin.Server.Implementations.Tests/Library/IgnorePatternsTests.cs +++ b/tests/Jellyfin.Server.Implementations.Tests/Library/IgnorePatternsTests.cs @@ -28,6 +28,10 @@ namespace Jellyfin.Server.Implementations.Tests.Library [InlineData("/directory/@Recycle/file.mp3", true)] [InlineData("/media/movies/.@__thumb", true)] [InlineData("/media/movies/.@__thumb/foo-bar-thumbnail.png", true)] + [InlineData("/media/music/Foo B.A.R./epic.flac", false)] + [InlineData("/media/music/Foo B.A.R", false)] + // This test is pending an upstream fix: https://github.com/dazinator/DotNet.Glob/issues/78 + // [InlineData("/media/music/Foo B.A.R.", false)] public void PathIgnored(string path, bool expected) { Assert.Equal(expected, IgnorePatterns.ShouldIgnore(path)); -- cgit v1.2.3 From 9314a4fcc92bb0c348cc56c6c20503c9d16d8b68 Mon Sep 17 00:00:00 2001 From: Odd Stråbø Date: Sun, 26 Jul 2020 23:28:25 +0200 Subject: . --- Emby.Server.Implementations/Library/IgnorePatterns.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'Emby.Server.Implementations/Library/IgnorePatterns.cs') diff --git a/Emby.Server.Implementations/Library/IgnorePatterns.cs b/Emby.Server.Implementations/Library/IgnorePatterns.cs index 8a85c852a..e30a67593 100644 --- a/Emby.Server.Implementations/Library/IgnorePatterns.cs +++ b/Emby.Server.Implementations/Library/IgnorePatterns.cs @@ -21,16 +21,17 @@ namespace Emby.Server.Implementations.Library // We have neither non-greedy matching or character group repetitions, working around that here. // https://github.com/dazinator/DotNet.Glob#patterns + // .*/sample\..{1,5} + "**/sample.?", + "**/sample.??", + "**/sample.???", // Matches sample.mkv + "**/sample.????", // Matches sample.webm + "**/sample.?????", "**/*.sample.?", "**/*.sample.??", "**/*.sample.???", "**/*.sample.????", "**/*.sample.?????", - "**/sample.?", - "**/sample.??", - "**/sample.???", - "**/sample.????", - "**/sample.?????", "**/sample/*", // Directories -- cgit v1.2.3