mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 15:32:31 +01:00
PostDownloadScanJob will not fail completely if a single folder fails.
This commit is contained in:
parent
2a64014c96
commit
8b0c8afb81
@ -31,7 +31,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
|||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return "Post Download Media File Scan"; }
|
get { return "Drop folder monitor"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public int DefaultInterval
|
public int DefaultInterval
|
||||||
@ -58,36 +58,43 @@ namespace NzbDrone.Core.Providers.Jobs
|
|||||||
|
|
||||||
foreach (var subfolder in _diskProvider.GetDirectories(dropFolder))
|
foreach (var subfolder in _diskProvider.GetDirectories(dropFolder))
|
||||||
{
|
{
|
||||||
var subfolderInfo = new DirectoryInfo(subfolder);
|
try
|
||||||
|
|
||||||
if (subfolderInfo.Name.StartsWith("_UNPACK_", StringComparison.CurrentCultureIgnoreCase))
|
|
||||||
{
|
{
|
||||||
Logger.Info("Folder [{0}] is still being unpacked. skipping.", subfolder);
|
var subfolderInfo = new DirectoryInfo(subfolder);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (subfolderInfo.Name.StartsWith("_FAILED_", StringComparison.CurrentCultureIgnoreCase))
|
if (subfolderInfo.Name.StartsWith("_UNPACK_", StringComparison.CurrentCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
Logger.Info("Folder [{0}] is still being unpacked. skipping.", subfolder);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subfolderInfo.Name.StartsWith("_FAILED_", StringComparison.CurrentCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
Logger.Info("Folder [{0}] is marked as failed. skipping.", subfolder);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Parse the Folder name
|
||||||
|
var seriesName = Parser.ParseSeriesName(subfolderInfo.Name);
|
||||||
|
var series = _seriesProvider.FindSeries(seriesName);
|
||||||
|
|
||||||
|
if (series == null)
|
||||||
|
{
|
||||||
|
Logger.Warn("Unable to Import new download, series is not being watched");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var importedFiles = _diskScanProvider.Scan(series, subfolder);
|
||||||
|
importedFiles.ForEach(file => _diskScanProvider.MoveEpisodeFile(file));
|
||||||
|
|
||||||
|
//Delete the folder only if all files were removed
|
||||||
|
if (_diskProvider.GetFiles(subfolder, "*.*", SearchOption.AllDirectories).Length == 0)
|
||||||
|
_diskProvider.DeleteFolder(subfolder, false);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.Info("Folder [{0}] is marked as failed. skipping.", subfolder);
|
Logger.ErrorException("An error has occurred while importing " + subfolder, e);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Parse the Folder name
|
|
||||||
var seriesName = Parser.ParseSeriesName(subfolderInfo.Name);
|
|
||||||
var series = _seriesProvider.FindSeries(seriesName);
|
|
||||||
|
|
||||||
if (series == null)
|
|
||||||
{
|
|
||||||
Logger.Warn("Unable to Import new download, series is not being watched");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var importedFiles = _diskScanProvider.Scan(series, subfolder);
|
|
||||||
importedFiles.ForEach(file => _diskScanProvider.MoveEpisodeFile(file));
|
|
||||||
|
|
||||||
//Delete the folder only if all files were removed
|
|
||||||
if (_diskProvider.GetFiles(subfolder, "*.*", SearchOption.AllDirectories).Length == 0)
|
|
||||||
_diskProvider.DeleteFolder(subfolder, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Debug("New Download Scan Job completed successfully");
|
Logger.Debug("New Download Scan Job completed successfully");
|
||||||
|
Loading…
Reference in New Issue
Block a user