Revert "omitlog" - there is already an if exists check
This reverts commit a2a74e2166.
This commit is contained in:
@@ -52,8 +52,6 @@ export const ffmpegExec = async (
|
||||
writeToTemporaryFile: writeToTemporaryInputFile,
|
||||
} = await makeFileForDataOrPathOrZipItem(dataOrPathOrZipItem);
|
||||
|
||||
let success = false;
|
||||
|
||||
const outputFilePath = await makeTempFilePath(outputFileExtension);
|
||||
try {
|
||||
await writeToTemporaryInputFile();
|
||||
@@ -65,16 +63,12 @@ export const ffmpegExec = async (
|
||||
);
|
||||
|
||||
await execAsync(cmd);
|
||||
// execAsync will throw on non-zero exitCode.
|
||||
success = true;
|
||||
|
||||
return await fs.readFile(outputFilePath);
|
||||
} finally {
|
||||
if (isInputFileTemporary)
|
||||
await deleteTempFileIgnoringErrors(inputFilePath);
|
||||
await deleteTempFileIgnoringErrors(outputFilePath, {
|
||||
omitLog: !success,
|
||||
});
|
||||
await deleteTempFileIgnoringErrors(outputFilePath);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -67,20 +67,12 @@ export const deleteTempFile = async (tempFilePath: string) => {
|
||||
* A variant of {@link deleteTempFile} that suppresses any errors, making it
|
||||
* safe to call them in a sequence without needing to handle the scenario where
|
||||
* one of them failing causes the rest to be skipped.
|
||||
*
|
||||
* @param opts - {@link omitLog} If set, an error message will not be logged if
|
||||
* the file cannot be deleted. This is convenient when we're trying to delete a
|
||||
* file which might not even exist, and so the error is expected.
|
||||
*/
|
||||
export const deleteTempFileIgnoringErrors = async (
|
||||
tempFilePath: string,
|
||||
opts?: { omitLog?: boolean },
|
||||
) => {
|
||||
export const deleteTempFileIgnoringErrors = async (tempFilePath: string) => {
|
||||
try {
|
||||
await deleteTempFile(tempFilePath);
|
||||
} catch (e) {
|
||||
if (!opts?.omitLog)
|
||||
log.error(`Failed to delete temporary file ${tempFilePath}`, e);
|
||||
log.error(`Could not delete temporary file at path ${tempFilePath}`, e);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user