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