Fixed: Ignore .AppleDouble subfolders of season folder

pull/6/head
Mark McDowall 10 years ago
parent 53029fe928
commit e466c77487

@ -162,5 +162,25 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
Mocker.GetMock<IMakeImportDecision>() Mocker.GetMock<IMakeImportDecision>()
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once()); .Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
} }
[Test]
public void should_not_scan_subfolder_of_season_folder_that_starts_with_a_period()
{
GivenParentFolderExists();
GivenFiles(new List<string>
{
Path.Combine(_series.Path, "Season 1", ".@__thumb", "file1.mkv").AsOsAgnostic(),
Path.Combine(_series.Path, "Season 1", ".@__THUMB", "file2.mkv").AsOsAgnostic(),
Path.Combine(_series.Path, "Season 1", ".hidden", "file2.mkv").AsOsAgnostic(),
Path.Combine(_series.Path, "Season 1", ".AppleDouble", "s01e01.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());
}
} }
} }

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -57,7 +58,8 @@ namespace NzbDrone.Core.MediaFiles
_logger = logger; _logger = logger;
} }
private static readonly Regex ExcludedSubFoldersRegex = new Regex(@"(extras|^\..+)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex ExcludedSubFoldersRegex = new Regex(@"(extras)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex ExcludedFoldersRegex = new Regex(@"(?:\\|\/)(\..+)(?:\\|\/)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
public void Scan(Series series) public void Scan(Series series)
{ {
@ -98,7 +100,8 @@ namespace NzbDrone.Core.MediaFiles
} }
var videoFilesStopwatch = Stopwatch.StartNew(); var videoFilesStopwatch = Stopwatch.StartNew();
var mediaFileList = GetVideoFiles(series.Path).Where(file => !ExcludedSubFoldersRegex.IsMatch(series.Path.GetRelativePath(file))).ToList(); var mediaFileList = FilterFiles(series, GetVideoFiles(series.Path)).ToList();
videoFilesStopwatch.Stop(); videoFilesStopwatch.Stop();
_logger.Trace("Finished getting episode files for: {0} [{1}]", series, videoFilesStopwatch.Elapsed); _logger.Trace("Finished getting episode files for: {0} [{1}]", series, videoFilesStopwatch.Elapsed);
@ -126,6 +129,12 @@ namespace NzbDrone.Core.MediaFiles
return mediaFileList.ToArray(); return mediaFileList.ToArray();
} }
private IEnumerable<string> FilterFiles(Series series, IEnumerable<string> videoFiles)
{
return videoFiles.Where(file => !ExcludedSubFoldersRegex.IsMatch(series.Path.GetRelativePath(file)))
.Where(file => !ExcludedFoldersRegex.IsMatch(file));
}
private void SetPermissions(String path) private void SetPermissions(String path)
{ {
if (!_configService.SetPermissionsLinux) if (!_configService.SetPermissionsLinux)

Loading…
Cancel
Save