Stricter rejection of series subfolders

Fixed: Exclude .@__thumb folders from series disk scans

Fixes #538
pull/6/head
Mark McDowall 10 years ago
parent 213f905767
commit 96578ca59b

@ -28,8 +28,6 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
Mocker.GetMock<IDiskProvider>()
.Setup(s => s.GetParentFolder(It.IsAny<string>()))
.Returns((string path) => Directory.GetParent(path).FullName);
}
private void GivenParentFolderExists()
@ -180,7 +178,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
}
[Test]
public void should_not_scan_Ssynology_eaDir()
public void should_not_scan_Synology_eaDir()
{
GivenParentFolderExists();
@ -195,5 +193,40 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
Mocker.GetMock<IMakeImportDecision>()
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
}
[Test]
public void should_not_scan_thumb_folder()
{
GivenParentFolderExists();
GivenFiles(new List<string>
{
Path.Combine(_series.Path, ".@__thumb", "file1.mkv").AsOsAgnostic(),
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
});
Subject.Scan(_series);
Mocker.GetMock<IMakeImportDecision>()
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
}
[Test]
public void should_scan_dotHack_folder()
{
GivenParentFolderExists();
_series.Path = @"C:\Test\TV\.hack".AsOsAgnostic();
GivenFiles(new List<string>
{
Path.Combine(_series.Path, "Season 1", "file1.mkv").AsOsAgnostic(),
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
});
Subject.Scan(_series);
Mocker.GetMock<IMakeImportDecision>()
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 2), _series), Times.Once());
}
}
}

@ -58,8 +58,7 @@ namespace NzbDrone.Core.MediaFiles
_logger = logger;
}
private static readonly Regex ExcludedSubFoldersRegex = new Regex(@"(extras|@eadir)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex ExcludedFoldersRegex = new Regex(@"(?:\\|\/)(\..+)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex ExcludedSubFoldersRegex = new Regex(@"(?:\\|\/|^)(extras|@eadir|\..+)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex ExcludedFilesRegex = new Regex(@"^\._", RegexOptions.Compiled | RegexOptions.IgnoreCase);
public void Scan(Series series)
@ -136,7 +135,6 @@ namespace NzbDrone.Core.MediaFiles
private IEnumerable<string> FilterFiles(Series series, IEnumerable<string> videoFiles)
{
return videoFiles.Where(file => !ExcludedSubFoldersRegex.IsMatch(series.Path.GetRelativePath(file)))
.Where(file => !ExcludedFoldersRegex.IsMatch(file))
.Where(file => !ExcludedFilesRegex.IsMatch(Path.GetFileName(file)));
}

Loading…
Cancel
Save