From f9b1e976d71f538decbfe15790cfa9df25b73463 Mon Sep 17 00:00:00 2001 From: dinglili Date: Thu, 8 Aug 2024 09:57:14 +0800 Subject: [PATCH] =?UTF-8?q?fixed:=20=E6=8F=92=E4=BB=B6=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic154cc646f0702d380c3f1b793ca260ec863de43 --- .../issue/electron-main/deployMainService.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/vs/platform/issue/electron-main/deployMainService.ts b/src/vs/platform/issue/electron-main/deployMainService.ts index 40f990f9..c3d505e3 100644 --- a/src/vs/platform/issue/electron-main/deployMainService.ts +++ b/src/vs/platform/issue/electron-main/deployMainService.ts @@ -221,12 +221,14 @@ export class DeployMainService implements IDeployMainService { listenerInstallProcess = async (event: IpcMainEvent, msg: any) => { if (msg.type === 'installExt') { + const logFile0 = this.installConfig + '/log/extInstall.1.log'; if (!fs.existsSync(logFile0)) { fs.mkdirSync(this.installConfig + "/log", { recursive: true }); } let installCommand = ""; + if (this.cancelFlag) return; try { const installItem = this.extDownloadPath + msg.downloadDone; if (this.environmentMainService.isBuilt) { @@ -245,7 +247,8 @@ export class DeployMainService implements IDeployMainService { } else { - this.installQueue?.push({ installCommand, msg }); + if (!this.cancelFlag) + this.installQueue?.push({ installCommand, msg }); } } catch (error) { this.logger.error(`安装 ext 执行出错 ${installCommand}: ${error.message}`); @@ -1063,7 +1066,6 @@ export class DeployMainService implements IDeployMainService { } } } - async executeNextInstall() { if (this.installQueue?.length === 0) { return; // 队列为空,结束执行 @@ -1098,6 +1100,8 @@ export class DeployMainService implements IDeployMainService { }; if (this.DeployWindow && !this.cancelFlag) { this.DeployWindow.webContents.send("kylinide.installWizard.msg", installMsg); + } else { + this.installQueue.splice(0); } } catch (error) { this.logger.error(`执行命令失败 ${installCommand}:${error.message}`); @@ -1114,19 +1118,22 @@ export class DeployMainService implements IDeployMainService { extTotal: this.extList.length, extName: msg.extName }; - if (this.DeployWindow) { + if (this.DeployWindow && !this.cancelFlag) { this.DeployWindow.webContents.send("kylinide.installWizard.msg", installMsg); + } else { + this.installQueue.splice(0); } } this.installQueue.shift(); // 执行完成后,将当前消息从队列中移除 if (!this.cancelFlag) await this.executeNextInstall(); // 继续执行下一个消息 + else { this.installQueue.splice(0) } } spawnCommand(command: string) { return new Promise((resolve, reject) => { - const child = spawn(command, { shell: true }); + const child = spawn('sh', ['-c', command], { detached: true }); let stdout = ''; let stderr = ''; @@ -1150,8 +1157,8 @@ export class DeployMainService implements IDeployMainService { const cancelTask = () => { if (child.pid) execSync(`kill -9 -${child.pid}`); - this.controller.signal.addEventListener('abort', cancelTask); } + this.controller.signal.addEventListener('abort', cancelTask); }); }