Revert "omitlog" - there is already an if exists check

This reverts commit a2a74e2166.
This commit is contained in:
Manav Rathi
2025-04-17 10:13:03 +05:30
parent a2a74e2166
commit c2efd198a6
2 changed files with 3 additions and 17 deletions

View File

@@ -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);
}
};

View File

@@ -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);
}
};