mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01:00
parent
6e7a2af86b
commit
c3acfe34fe
@ -27,6 +27,11 @@ public void Setup()
|
|||||||
@"C:\Test\movie"
|
@"C:\Test\movie"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GivenFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GivenFiles()
|
||||||
|
{
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(s => s.GetFiles(It.IsAny<String>(), SearchOption.AllDirectories))
|
.Setup(s => s.GetFiles(It.IsAny<String>(), SearchOption.AllDirectories))
|
||||||
.Returns(_files);
|
.Returns(_files);
|
||||||
@ -69,8 +74,20 @@ public void should_check_top_level_directory_only_when_allDirectories_is_false()
|
|||||||
public void should_return_video_files_only()
|
public void should_return_video_files_only()
|
||||||
{
|
{
|
||||||
var path = @"C:\Test\";
|
var path = @"C:\Test\";
|
||||||
var test = Subject.GetVideoFiles(path);
|
|
||||||
Subject.GetVideoFiles(path).Should().HaveCount(4);
|
Subject.GetVideoFiles(path).Should().HaveCount(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_exclude_osx_metadata_files()
|
||||||
|
{
|
||||||
|
var path = @"C:\Test\";
|
||||||
|
|
||||||
|
_files = new [] { "._24 The Status Quo Combustion.mp4", "24 The Status Quo Combustion.mp4" };
|
||||||
|
|
||||||
|
GivenFiles();
|
||||||
|
|
||||||
|
Subject.GetVideoFiles(path).Should().HaveCount(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,7 @@ public DiskScanService(IDiskProvider diskProvider,
|
|||||||
|
|
||||||
private static readonly Regex ExcludedSubFoldersRegex = new Regex(@"(extras|@eadir)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
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 ExcludedFoldersRegex = new Regex(@"(?:\\|\/)(\..+)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
private static readonly Regex ExcludedFilesRegex = new Regex(@"^\._", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
public void Scan(Series series)
|
public void Scan(Series series)
|
||||||
{
|
{
|
||||||
@ -124,7 +125,9 @@ public string[] GetVideoFiles(string path, bool allDirectories = true)
|
|||||||
var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
||||||
var filesOnDisk = _diskProvider.GetFiles(path, searchOption);
|
var filesOnDisk = _diskProvider.GetFiles(path, searchOption);
|
||||||
|
|
||||||
var mediaFileList = filesOnDisk.Where(c => MediaFileExtensions.Extensions.Contains(Path.GetExtension(c).ToLower())).ToList();
|
var mediaFileList = filesOnDisk.Where(file => MediaFileExtensions.Extensions.Contains(Path.GetExtension(file).ToLower()))
|
||||||
|
.Where(file => !ExcludedFilesRegex.IsMatch(Path.GetFileName(file)))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
_logger.Debug("{0} video files were found in {1}", mediaFileList.Count, path);
|
_logger.Debug("{0} video files were found in {1}", mediaFileList.Count, path);
|
||||||
return mediaFileList.ToArray();
|
return mediaFileList.ToArray();
|
||||||
@ -133,7 +136,8 @@ public string[] GetVideoFiles(string path, bool allDirectories = true)
|
|||||||
private IEnumerable<string> FilterFiles(Series series, IEnumerable<string> videoFiles)
|
private IEnumerable<string> FilterFiles(Series series, IEnumerable<string> videoFiles)
|
||||||
{
|
{
|
||||||
return videoFiles.Where(file => !ExcludedSubFoldersRegex.IsMatch(series.Path.GetRelativePath(file)))
|
return videoFiles.Where(file => !ExcludedSubFoldersRegex.IsMatch(series.Path.GetRelativePath(file)))
|
||||||
.Where(file => !ExcludedFoldersRegex.IsMatch(file));
|
.Where(file => !ExcludedFoldersRegex.IsMatch(file))
|
||||||
|
.Where(file => !ExcludedFilesRegex.IsMatch(Path.GetFileName(file)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetPermissions(String path)
|
private void SetPermissions(String path)
|
||||||
|
Loading…
Reference in New Issue
Block a user