From d54cf8262ac01a3deb6b8dd7689ec144d4d09ea8 Mon Sep 17 00:00:00 2001 From: mei23 Date: Mon, 13 Jun 2022 21:54:10 +0900 Subject: [PATCH] fix cleanup --- .../backend/src/services/drive/generate-video-thumbnail.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/services/drive/generate-video-thumbnail.ts b/packages/backend/src/services/drive/generate-video-thumbnail.ts index 6e6666481d..b6ca4e152e 100644 --- a/packages/backend/src/services/drive/generate-video-thumbnail.ts +++ b/packages/backend/src/services/drive/generate-video-thumbnail.ts @@ -6,6 +6,8 @@ import FFmpeg from 'fluent-ffmpeg'; export async function GenerateVideoThumbnail(source: string): Promise { const [dir, cleanup] = await createTempDir(); + const outFile = `${dir}/out.png`; + try { await new Promise((res, rej) => { FFmpeg({ @@ -22,8 +24,9 @@ export async function GenerateVideoThumbnail(source: string): Promise { }); // JPEGに変換 (Webpでもいいが、MastodonはWebpをサポートせず表示できなくなる) - return await convertToJpeg(`${dir}/out.png`, 498, 280); + return await convertToJpeg(outFile, 498, 280); } finally { + await fs.promises.unlink(outFile); cleanup(); } }