|
|
|
@ -105,33 +105,43 @@ namespace NzbDrone.Core.MediaFiles
|
|
|
|
|
|
|
|
|
|
public bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Series series)
|
|
|
|
|
{
|
|
|
|
|
var videoFiles = _diskScanService.GetVideoFiles(directoryInfo.FullName);
|
|
|
|
|
var rarFiles = _diskProvider.GetFiles(directoryInfo.FullName, SearchOption.AllDirectories).Where(f => Path.GetExtension(f).Equals(".rar", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
foreach (var videoFile in videoFiles)
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var episodeParseResult = Parser.Parser.ParseTitle(Path.GetFileName(videoFile));
|
|
|
|
|
var videoFiles = _diskScanService.GetVideoFiles(directoryInfo.FullName);
|
|
|
|
|
var rarFiles = _diskProvider.GetFiles(directoryInfo.FullName, SearchOption.AllDirectories).Where(f =>
|
|
|
|
|
Path.GetExtension(f).Equals(".rar", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
if (episodeParseResult == null)
|
|
|
|
|
foreach (var videoFile in videoFiles)
|
|
|
|
|
{
|
|
|
|
|
_logger.Warn("Unable to parse file on import: [{0}]", videoFile);
|
|
|
|
|
return false;
|
|
|
|
|
var episodeParseResult = Parser.Parser.ParseTitle(Path.GetFileName(videoFile));
|
|
|
|
|
|
|
|
|
|
if (episodeParseResult == null)
|
|
|
|
|
{
|
|
|
|
|
_logger.Warn("Unable to parse file on import: [{0}]", videoFile);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_detectSample.IsSample(series, videoFile, episodeParseResult.IsPossibleSpecialEpisode) !=
|
|
|
|
|
DetectSampleResult.Sample)
|
|
|
|
|
{
|
|
|
|
|
_logger.Warn("Non-sample file detected: [{0}]", videoFile);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_detectSample.IsSample(series, videoFile, episodeParseResult.IsPossibleSpecialEpisode) != DetectSampleResult.Sample)
|
|
|
|
|
if (rarFiles.Any(f => _diskProvider.GetFileSize(f) > 10.Megabytes()))
|
|
|
|
|
{
|
|
|
|
|
_logger.Warn("Non-sample file detected: [{0}]", videoFile);
|
|
|
|
|
_logger.Warn("RAR file detected, will require manual cleanup");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rarFiles.Any(f => _diskProvider.GetFileSize(f) > 10.Megabytes()))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (DirectoryNotFoundException e)
|
|
|
|
|
{
|
|
|
|
|
_logger.Warn("RAR file detected, will require manual cleanup");
|
|
|
|
|
_logger.Debug(e, "Folder {0} has already been removed", directoryInfo.FullName);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<ImportResult> ProcessFolder(DirectoryInfo directoryInfo, ImportMode importMode, DownloadClientItem downloadClientItem)
|
|
|
|
|