Only copy files if conversion succeeded.

This commit is contained in:
Michael Bucari-Tovo 2022-06-20 09:04:06 -06:00
parent c51489ac74
commit fdee254020

View File

@ -59,13 +59,19 @@ namespace FileLiberator
m4bBook.InputStream.Close(); m4bBook.InputStream.Close();
mp3File.Close(); mp3File.Close();
if (result == ConversionResult.Failed)
{
FileUtility.SaferDelete(mp3File.Name);
return new StatusHandler { "Conversion failed" };
}
else if (result == ConversionResult.Cancelled)
{
FileUtility.SaferDelete(mp3File.Name);
return new StatusHandler { "Cancelled" };
}
var realMp3Path = FileUtility.SaferMoveToValidPath(mp3File.Name, proposedMp3Path); var realMp3Path = FileUtility.SaferMoveToValidPath(mp3File.Name, proposedMp3Path);
OnFileCreated(libraryBook, realMp3Path); OnFileCreated(libraryBook, realMp3Path);
if (result == ConversionResult.Failed)
return new StatusHandler { "Conversion failed" };
else if (result == ConversionResult.Cancelled)
return new StatusHandler { "Cancelled" };
} }
return new StatusHandler(); return new StatusHandler();
} }