Fixed a bug when trying to clean up an episode that was still attached to an episode file that no longer existed.

Wrapped processing of file in try/catch to prevent one failure from affecting the other files.
pull/4/head
Mark McDowall 14 years ago
parent 5041ff550c
commit cea511a460

@ -232,6 +232,10 @@ namespace NzbDrone.Core.Providers
foreach (var file in files) foreach (var file in files)
{ {
try
{
//Parse the filename //Parse the filename
var parseResult = Parser.ParseEpisodeInfo(Path.GetFileName(file)); var parseResult = Parser.ParseEpisodeInfo(Path.GetFileName(file));
parseResult.Series = series; parseResult.Series = series;
@ -270,7 +274,12 @@ namespace NzbDrone.Core.Providers
} }
//Delete the files and then cleanup! //Delete the files and then cleanup!
episodeFilesToClean.ForEach(e => _diskProvider.DeleteFile(e.Path)); foreach (var e in episodeFilesToClean)
{
if (_diskProvider.FileExists(e.Path))
_diskProvider.DeleteFile(e.Path);
}
CleanUp(episodeFilesToClean); CleanUp(episodeFilesToClean);
//Move the file //Move the file
@ -280,6 +289,12 @@ namespace NzbDrone.Core.Providers
result.Add(ImportFile(series, folder + filename)); result.Add(ImportFile(series, folder + filename));
} }
catch (Exception ex)
{
Logger.WarnException("Error importing new download: " + file, ex);
}
}
//If we have imported all the non-sample files, delete the folder, requires a minimum of 1 file to be imported. //If we have imported all the non-sample files, delete the folder, requires a minimum of 1 file to be imported.
if (files.Count() > 0 && files.Count() == result.Count) if (files.Count() > 0 && files.Count() == result.Count)
{ {

Loading…
Cancel
Save