From 33dbc8a1112fe132e5410ac7bfc5b890ece20f09 Mon Sep 17 00:00:00 2001 From: Angel Wang Date: Tue, 23 Jun 2026 00:05:20 -0600 Subject: [PATCH] fix(analyze): check whether cache exists before manipulating it --- src/analyze/index.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/analyze/index.ts b/src/analyze/index.ts index e30fb56..7b558bc 100755 --- a/src/analyze/index.ts +++ b/src/analyze/index.ts @@ -18,11 +18,10 @@ if (config == undefined) { console.debug(chalkDebug(`Config: \n${JSON.stringify(config, null, 4)}`)) -await fs.cp(cachePath, `${cachePath}.bak`, { force: true }, (err: Error) => { - if (err) { - console.log(err) - } -}) +if (fs.statSync(cachePath)) { + await fs.cp(cachePath, `${cachePath}.bak`, { force: true }) +} + const imageData = { files: [] } as ImageAnalysisData @@ -30,4 +29,6 @@ await runPreAnalysis(config.preAnalysisCommands) await analyzeImages(config.imageDir, imageData, cachePath) -await fs.rm(`${cachePath}.bak`, { force: true }) +if (fs.statSync(`${cachePath}.bak`)) { + await fs.rm(`${cachePath}.bak`, { force: true }) +} -- 2.51.2