mirror of
https://github.com/Readarr/Readarr
synced 2026-01-01 21:24:52 +01:00
Fixed: Re-processing imported download causing task to fail
This commit is contained in:
parent
cc6db7a9e5
commit
b9ba7228b5
1 changed files with 22 additions and 14 deletions
|
|
@ -110,30 +110,38 @@ public List<ImportResult> ProcessPath(string path, ImportMode importMode = Impor
|
|||
|
||||
public bool ShouldDeleteFolder(IDirectoryInfo directoryInfo, Author author)
|
||||
{
|
||||
var bookFiles = _diskScanService.GetBookFiles(directoryInfo.FullName);
|
||||
var rarFiles = _diskProvider.GetFiles(directoryInfo.FullName, SearchOption.AllDirectories).Where(f => Path.GetExtension(f).Equals(".rar", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
foreach (var bookFile in bookFiles)
|
||||
try
|
||||
{
|
||||
var bookParseResult = Parser.Parser.ParseTitle(bookFile.Name);
|
||||
var bookFiles = _diskScanService.GetBookFiles(directoryInfo.FullName);
|
||||
var rarFiles = _diskProvider.GetFiles(directoryInfo.FullName, SearchOption.AllDirectories).Where(f => Path.GetExtension(f).Equals(".rar", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (bookParseResult == null)
|
||||
foreach (var bookFile in bookFiles)
|
||||
{
|
||||
_logger.Warn("Unable to parse file on import: [{0}]", bookFile);
|
||||
var bookParseResult = Parser.Parser.ParseTitle(bookFile.Name);
|
||||
|
||||
if (bookParseResult == null)
|
||||
{
|
||||
_logger.Warn("Unable to parse file on import: [{0}]", bookFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
_logger.Warn("Book file detected: [{0}]", bookFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
_logger.Warn("Book file detected: [{0}]", bookFile);
|
||||
return false;
|
||||
}
|
||||
if (rarFiles.Any(f => _diskProvider.GetFileSize(f) > 10.Megabytes()))
|
||||
{
|
||||
_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(IDirectoryInfo directoryInfo, ImportMode importMode, DownloadClientItem downloadClientItem)
|
||||
|
|
|
|||
Loading…
Reference in a new issue