From 11d5410dbb2df9e6c4e5ad5de4cc5db741014c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Sat, 25 Jul 2020 23:50:49 +0200 Subject: [PATCH 1/5] 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. --- .../Library/IgnorePatterns.cs | 19 ++++++++++++++++--- .../Library/IgnorePatternsTests.cs | 10 +++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) 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)); From 800260af431fb7cb905993fdc1e3566e43154a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Sun, 26 Jul 2020 00:19:24 +0200 Subject: [PATCH 2/5] Yep. I failed at copy-pasting. --- Emby.Server.Implementations/Library/IgnorePatterns.cs | 2 ++ 1 file changed, 2 insertions(+) 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/*", From de708d2fca268eb470b34013f4a52493e34908a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Sun, 26 Jul 2020 17:11:43 +0200 Subject: [PATCH 3/5] Comment --- Emby.Server.Implementations/Library/IgnorePatterns.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.???", From 7fa80ac3e0695eaf279eeef6ac643044f0e399ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Sun, 26 Jul 2020 23:02:11 +0200 Subject: [PATCH 4/5] Add more tests, update comment --- Emby.Server.Implementations/Library/IgnorePatterns.cs | 1 + .../Library/IgnorePatternsTests.cs | 4 ++++ 2 files changed, 5 insertions(+) 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)); From 9314a4fcc92bb0c348cc56c6c20503c9d16d8b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Sun, 26 Jul 2020 23:28:25 +0200 Subject: [PATCH 5/5] . --- Emby.Server.Implementations/Library/IgnorePatterns.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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