chore: fix check script

This commit is contained in:
GyDi 2023-07-23 13:11:17 +08:00
parent 9ea08f4fed
commit e8eb68bf24
No known key found for this signature in database
GPG Key ID: 9C3AD40F1F99880A

View File

@ -123,8 +123,9 @@ async function resolveSidecar(binInfo) {
await fs.mkdirp(tempDir); await fs.mkdirp(tempDir);
try { try {
if (!(await fs.pathExists(tempZip))) if (!(await fs.pathExists(tempZip))) {
await downloadFile(downloadURL, tempZip); await downloadFile(downloadURL, tempZip);
}
if (zipFile.endsWith(".zip")) { if (zipFile.endsWith(".zip")) {
const zip = new AdmZip(tempZip); const zip = new AdmZip(tempZip);
@ -140,7 +141,7 @@ async function resolveSidecar(binInfo) {
const writeStream = fs.createWriteStream(sidecarPath); const writeStream = fs.createWriteStream(sidecarPath);
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
const onError = (error) => { const onError = (error) => {
console.error(`[ERROR]: "${name}" gz failed`, error.message); console.error(`[ERROR]: "${name}" gz failed:`, error.message);
reject(error); reject(error);
}; };
readStream readStream
@ -156,6 +157,8 @@ async function resolveSidecar(binInfo) {
}); });
} }
} catch (err) { } catch (err) {
// 需要删除文件
await fs.remove(sidecarPath);
throw err; throw err;
} finally { } finally {
// delete temp dir // delete temp dir
@ -318,7 +321,8 @@ async function runTask() {
await task.func(); await task.func();
break; break;
} catch (err) { } catch (err) {
console.error(`[ERROR]: task::${task.name} try ${i} == `, err.message); console.error(`[ERROR]: task::${task.name} try ${i} ==`, err.message);
if (i === task.retry - 1) throw err;
} }
} }
return runTask(); return runTask();