From 9a3e89f2834ceca9fa0192fcb54a5161d300b910 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Thu, 26 Sep 2024 14:32:53 +0300 Subject: [PATCH] Fixed: Ignore '.DS_Store' and '.unmanic' when scanning for files --- .../DiskScanServiceTests/ScanFixture.cs | 24 +++++++++++++++++++ .../MediaFiles/DiskScanService.cs | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs index b18035541..5a1900fc5 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs @@ -8,7 +8,9 @@ using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.MediaFiles.MovieImport; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Movies; using NzbDrone.Core.RootFolders; using NzbDrone.Core.Test.Framework; @@ -424,5 +426,27 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests Mocker.GetMock() .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _movie, false), Times.Once()); } + + [Test] + public void should_not_scan_excluded_files() + { + GivenMovieFolder(); + + GivenFiles(new List + { + Path.Combine(_movie.Path, ".DS_Store").AsOsAgnostic(), + Path.Combine(_movie.Path, ".unmanic").AsOsAgnostic(), + Path.Combine(_movie.Path, ".unmanic.part").AsOsAgnostic(), + Path.Combine(_movie.Path, "24 The Status Quo Combustion.mkv").AsOsAgnostic() + }); + + Subject.Scan(_movie); + + Mocker.GetMock() + .Verify(v => v.GetImportDecisions(It.Is>(l => l.Count == 1), _movie, false), Times.Once()); + + Mocker.GetMock() + .Verify(v => v.PublishEvent(It.Is(c => c.Movie != null && c.PossibleExtraFiles.Count == 0)), Times.Once()); + } } } diff --git a/src/NzbDrone.Core/MediaFiles/DiskScanService.cs b/src/NzbDrone.Core/MediaFiles/DiskScanService.cs index 2600750ec..3a8223521 100644 --- a/src/NzbDrone.Core/MediaFiles/DiskScanService.cs +++ b/src/NzbDrone.Core/MediaFiles/DiskScanService.cs @@ -72,7 +72,7 @@ namespace NzbDrone.Core.MediaFiles private static readonly Regex ExcludedExtrasSubFolderRegex = new Regex(@"(?:\\|\/|^)(?:extras|extrafanart|behind the scenes|deleted scenes|featurettes|interviews|other|scenes|sample[s]?|shorts|trailers)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex ExcludedSubFoldersRegex = new Regex(@"(?:\\|\/|^)(?:@eadir|\.@__thumb|plex versions|\.[^\\/]+)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex ExcludedExtraFilesRegex = new Regex(@"(-(trailer|other|behindthescenes|deleted|featurette|interview|scene|short)\.[^.]+$)", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex ExcludedFilesRegex = new Regex(@"^\._|^Thumbs\.db$", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex ExcludedFilesRegex = new Regex(@"^\.(_|unmanic|DS_Store$)|^Thumbs\.db$", RegexOptions.Compiled | RegexOptions.IgnoreCase); public void Scan(Movie movie) {