mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-05 02:22:31 +01:00
Stricter rejection of series subfolders
Fixed: Exclude .@__thumb folders from series disk scans Fixes #538
This commit is contained in:
parent
213f905767
commit
96578ca59b
@ -28,8 +28,6 @@ public void Setup()
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.GetParentFolder(It.IsAny<string>()))
|
||||
.Returns((string path) => Directory.GetParent(path).FullName);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void GivenParentFolderExists()
|
||||
@ -180,7 +178,7 @@ public void should_not_scan_subfolder_of_season_folder_that_starts_with_a_period
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_scan_Ssynology_eaDir()
|
||||
public void should_not_scan_Synology_eaDir()
|
||||
{
|
||||
GivenParentFolderExists();
|
||||
|
||||
@ -195,5 +193,40 @@ public void should_not_scan_Ssynology_eaDir()
|
||||
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 @@ public DiskScanService(IDiskProvider diskProvider,
|
||||
_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 @@ public string[] GetVideoFiles(string path, bool allDirectories = true)
|
||||
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…
Reference in New Issue
Block a user