1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-12 11:15:43 +02:00

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.
This commit is contained in:
Mark McDowall 2011-06-07 22:53:52 -07:00
parent 5041ff550c
commit cea511a460

View File

@ -232,6 +232,10 @@ public virtual List<EpisodeFile> ImportNewFiles(string path, Series series)
foreach (var file in files)
{
try
{
//Parse the filename
var parseResult = Parser.ParseEpisodeInfo(Path.GetFileName(file));
parseResult.Series = series;
@ -270,7 +274,12 @@ public virtual List<EpisodeFile> ImportNewFiles(string path, Series series)
}
//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);
//Move the file
@ -280,6 +289,12 @@ public virtual List<EpisodeFile> ImportNewFiles(string path, Series series)
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 (files.Count() > 0 && files.Count() == result.Count)
{