修复配置文件更新记录存放位置
This commit is contained in:
parent
719dc3b320
commit
599c2e2776
|
@ -193,10 +193,7 @@ export class DeployMainService implements IDeployMainService {
|
|||
this.logger.info("关闭窗口");
|
||||
//删除新下载但是没被使用的配置文件
|
||||
if (this.updateConfigDir) {
|
||||
// const selectdir = this.localConfigDir;
|
||||
this.logger.debug("this.updateConfgDir :", this.updateConfigDir);
|
||||
this.logger.debug("this.localConfigDir :", this.localConfigDir);
|
||||
if (this.updateConfigDir !== this.localConfigDir)
|
||||
if (this.selectObject.updateFlag == false)
|
||||
if (fs.existsSync(this.updateConfigDir))
|
||||
fs.rmdirSync(this.updateConfigDir, { recursive: true });
|
||||
}
|
||||
|
@ -927,172 +924,23 @@ export class DeployMainService implements IDeployMainService {
|
|||
// semaphore.release(); // 释放信号量
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
handleInitConfigVersify = async (event: IpcMainInvokeEvent, msg: any) => {
|
||||
//start configverify
|
||||
// updateConfigDir = msg.dst;
|
||||
let selectPageShow = 0;
|
||||
let message: string = "";
|
||||
logger.info("开始校验本地数据");
|
||||
this.localConfigObject = await this.localConfigVerify(this.localConfigDir, this.productService.IDEVersion);
|
||||
logger.info("本地数据校验结束");
|
||||
logger.info("开始下载校验网络数据");
|
||||
this.updateConfigObject = await this.downloadAndVerify(this.updateConfigDir, msg);
|
||||
logger.info("网络数据校验结束");
|
||||
//1.本地error ,net error -1;
|
||||
//2.本地error,net right 1;
|
||||
//3.本地 right ,net error 2;
|
||||
//4.本地right ,net right ,== 3
|
||||
//5.本地right ,net right , != 4
|
||||
//for test
|
||||
if (this.localConfigObject.res != 0 && this.updateConfigObject.res != 0) {
|
||||
if (this.DeployWindow) {
|
||||
if (this.localConfigObject.osinfo == "undefined" && this.updateConfigObject.osinfo == "undefined") {
|
||||
logger.error("安装引导器仅支持openKylin操作系统,脚本根据/etc/os-release信息判断操作系统类型");
|
||||
await dialog.showMessageBox(this.DeployWindow,
|
||||
{
|
||||
type: "error",
|
||||
title: "配置文件检查",
|
||||
buttons: ["OK"],
|
||||
detail: `点击【OK】按钮后,将跳过此引导步骤,请根据开发需要自行下载插件、安装软件依赖。具体信息请查看日志${this.installConfig}/log/instguide.log`,
|
||||
message: "安装引导器不支持当前系统。"
|
||||
});
|
||||
if (this.DeployWindow && this.DeployWindow != undefined)
|
||||
this.DeployWindow.close();
|
||||
// .then(result => {
|
||||
// if (this.DeployWindow && this.DeployWindow != undefined)
|
||||
// this.DeployWindow.close();
|
||||
// resolve(void 0);
|
||||
// })
|
||||
return void 0;
|
||||
} else {
|
||||
logger.error("本地数据及网络数据校验失败");
|
||||
await dialog.showMessageBox(this.DeployWindow,
|
||||
{
|
||||
type: "error",
|
||||
title: "配置文件检查",
|
||||
buttons: ["OK"],
|
||||
detail: `点击【OK】按钮后,将跳过此引导步骤,请根据开发需要自行下载插件、安装软件依赖。具体信息请查看日志${this.installConfig}/log/instguide.log`,
|
||||
message: "本地数据及网络数据校验失败"
|
||||
});
|
||||
if (this.DeployWindow && this.DeployWindow != undefined)
|
||||
this.DeployWindow.close();
|
||||
return void 0;
|
||||
// .then(result => {
|
||||
// if (this.DeployWindow && this.DeployWindow != undefined)
|
||||
// this.DeployWindow.close();
|
||||
// resolve(void 0);
|
||||
// })
|
||||
}
|
||||
}
|
||||
selectPageShow = -1;
|
||||
} else {
|
||||
|
||||
if (this.localConfigObject.res != 0 && this.updateConfigObject.res == 0) {
|
||||
|
||||
selectPageShow = 1;
|
||||
if (this.localConfigObject.osinfo == "undefined") {
|
||||
message = "本地配置文件不支持当前环境,选择更新选项";
|
||||
logger.error(message);
|
||||
} else {
|
||||
message = "本地配置文件已损坏,选择更新选项";
|
||||
logger.error("本地数据校验失败");
|
||||
}
|
||||
|
||||
} else if (this.localConfigObject.res == 0 && this.updateConfigObject.res != 0) {
|
||||
if (this.updateConfigObject.osinfo == "undefined") {
|
||||
message = "联网数据文件不支持当前环境";
|
||||
logger.error(message);
|
||||
} else {
|
||||
message = "网络数据文件校验失败";
|
||||
logger.error(message);
|
||||
}
|
||||
selectPageShow = 2;
|
||||
} else if (this.localConfigObject.res == 0 && this.updateConfigObject.res == 0) {
|
||||
if (installUtils.compareVersions(this.updateConfigObject.g_index_Object.ver, this.localConfigObject.g_index_Object.ver) > 0) {
|
||||
//显示询问用户是否更新配置文件
|
||||
//比较具体的配置文件是否一致,若是一致则还是选择本地配置,若是不同则
|
||||
let updateosinfo = this.updateConfigObject.osinfo;
|
||||
let localosinfo = this.localConfigObject.osinfo;
|
||||
if (this.updateConfigObject.g_index_Object["config-file"][updateosinfo][0]['sign-md5'] !== this.localConfigObject.g_index_Object["config-file"][localosinfo][0]['sign-md5'])
|
||||
selectPageShow = 4;
|
||||
else {
|
||||
logger.info("联网数据与本地配置文件数据版本一致");
|
||||
selectPageShow = 3;
|
||||
message = "联网数据与本地配置文件数据版本一致";
|
||||
}
|
||||
} else {
|
||||
selectPageShow = 3;
|
||||
logger.info("联网数据与本地配置文件数据版本一致");
|
||||
message = "联网数据与本地配置文件数据版本一致";
|
||||
}
|
||||
}
|
||||
console.log("selectPageShow:" + selectPageShow);
|
||||
let Data;
|
||||
if (selectPageShow == 0) {
|
||||
this.selectObject.depInfoJsonPath = this.localConfigDir + "/" + this.localConfigObject.depConfigInfo['file_name'];
|
||||
this.selectObject.extAddressPath = this.localConfigDir + "/" + this.localConfigObject.g_index_Object['ext-file']['file_name'];
|
||||
Data = {
|
||||
osinfo: this.localConfigObject.osinfo,
|
||||
selectPageShow: selectPageShow,
|
||||
type: "configVersify"
|
||||
}
|
||||
|
||||
} else {
|
||||
Data = {
|
||||
localConfigObject: this.localConfigObject,
|
||||
updateConfigObject: this.updateConfigObject,
|
||||
selectPageShow: selectPageShow,
|
||||
message: message,
|
||||
type: "configVersify"
|
||||
}
|
||||
}
|
||||
if (this.DeployWindow) {
|
||||
return Data;
|
||||
} else {
|
||||
return void 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
handleInitConfigSelect = async (event: IpcMainInvokeEvent, msg: any) => {
|
||||
let osinfo = "";
|
||||
if (msg.select === "local") {
|
||||
osinfo = this.localConfigObject.osinfo;
|
||||
this.selectObject.dirPath = this.localConfigDir;
|
||||
this.selectObject.updateFlag = false;
|
||||
this.selectObject.depInfoJsonPath = this.localConfigDir + "/" + this.localConfigObject.depConfigInfo['file_name'];
|
||||
this.selectObject.extAddressPath = this.localConfigDir + "/" + this.localConfigObject.g_index_Object['ext-file']['file_name'];
|
||||
} else if (msg.select === "update") {
|
||||
this.selectObject.dirPath = this.updateConfigDir;
|
||||
this.selectObject.updateFlag = true;
|
||||
osinfo = this.updateConfigObject.osinfo;
|
||||
this.selectObject.depInfoJsonPath = this.updateConfigDir + "/" + this.updateConfigObject.depConfigInfo['file_name'];
|
||||
this.selectObject.extAddressPath = this.updateConfigDir + "/" + this.updateConfigObject.g_index_Object['ext-file']['file_name']; //error
|
||||
|
||||
listenerWriteSelectJson = async (event: IpcMainEvent, msg: any) => {
|
||||
if (msg.type === "writeJson") {
|
||||
if (this.selectObject.updateFlag) {
|
||||
this.logger.info(`更新配置文件地址为:`, this.updateConfigDir);
|
||||
installUtils.modifyJsonProperty(path.join(this.installConfig, "selectFile.json"), "selectDir", this.updateConfigDir);
|
||||
}
|
||||
const { osFile, data } = this.readOSInfo();
|
||||
const osObject = {
|
||||
type: "osinfo",
|
||||
osinfo: osinfo,
|
||||
osFile: osFile,
|
||||
osData: data
|
||||
// else {
|
||||
// installUtils.modifyJsonProperty(this.installConfig + "/" + "selectFile.json", "selectDir", this.localConfigDir);
|
||||
// }
|
||||
} else if (msg.type === 'writeKey') {
|
||||
this.logger.info("保存选择的开发场景");
|
||||
installUtils.modifyJsonProperty(this.installConfig + "/" + "selectFile.json", "selectKey", msg.keys);
|
||||
}
|
||||
logger.info(`选择的配置文件名称:${this.selectObject.depInfoJsonPath}`);
|
||||
logger.info(`识别操作系统信息:${osinfo}`);
|
||||
|
||||
if (this.DeployWindow) {
|
||||
// this.DeployWindow.webContents.send('kylinide.installWizard.init', osObject);
|
||||
return osObject;
|
||||
}
|
||||
else {
|
||||
return void 0;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
private removeListeners(): void {
|
||||
this.logger.info("移除监听器");
|
||||
//接收从渲染进程发送的消息
|
||||
|
@ -1101,6 +949,7 @@ export class DeployMainService implements IDeployMainService {
|
|||
validatedIpcMain.removeListener('kylinide.installWizard.closeWizard', this.listenerCloseWindow);
|
||||
validatedIpcMain.removeListener('kylinide.installWizard.msg.process', this.listenerInstallProcess);
|
||||
validatedIpcMain.removeListener('kylinide.installWizard.removeFileLister', this.listenerRemoveFileLister);
|
||||
validatedIpcMain.removeListener('kylinide.installWizard.init', this.listenerWriteSelectJson);
|
||||
}
|
||||
private registerListeners(): void {
|
||||
this.logger.info("注册监听器");
|
||||
|
@ -1110,6 +959,8 @@ export class DeployMainService implements IDeployMainService {
|
|||
validatedIpcMain.on('kylinide.installWizard.closeWizard', this.listenerCloseWindow);
|
||||
validatedIpcMain.on('kylinide.installWizard.msg.process', this.listenerInstallProcess);
|
||||
validatedIpcMain.on('kylinide.installWizard.removeFileLister', this.listenerRemoveFileLister);
|
||||
validatedIpcMain.on('kylinide.installWizard.init', this.listenerWriteSelectJson);
|
||||
|
||||
//handle从渲染进程发送的消息
|
||||
validatedIpcMain.handle('kylinide.installWizard.init.configVersify', this.handleInitConfigVersify);
|
||||
validatedIpcMain.handle('kylinide.installWizard.init.configSelect', this.handleInitConfigSelect);
|
||||
|
@ -1317,7 +1168,7 @@ export class DeployMainService implements IDeployMainService {
|
|||
this.DeployWindow = null;
|
||||
validatedIpcMain.removeListener('kylinide.installWizard.skipWizard', listenerSkipWizard
|
||||
);
|
||||
validatedIpcMain.removeListener('kylinide.installWizard.init', listenerInit);
|
||||
// validatedIpcMain.removeListener('kylinide.installWizard.init', listenerInit);
|
||||
DeployDisposables.dispose();
|
||||
if (flag) {
|
||||
// 第一次打开时,关闭窗口,继续
|
||||
|
@ -1334,21 +1185,6 @@ export class DeployMainService implements IDeployMainService {
|
|||
}
|
||||
validatedIpcMain.on('kylinide.installWizard.skipWizard', listenerSkipWizard
|
||||
);
|
||||
const listenerInit = async (event: IpcMainEvent, msg: any) => {
|
||||
this.logger.info("接收消息:kylinide.installWizard.init");
|
||||
|
||||
if (msg.type === "writeJson") {
|
||||
if (this.selectObject.updateFlag) {
|
||||
installUtils.modifyJsonProperty(this.installConfig + "/" + "selectFile.json", "selectDir", this.updateConfigDir);
|
||||
} else {
|
||||
installUtils.modifyJsonProperty(this.installConfig + "/" + "selectFile.json", "selectDir", this.localConfigDir);
|
||||
}
|
||||
} else if (msg.type === 'writeKey') {
|
||||
installUtils.modifyJsonProperty(this.installConfig + "/" + "selectFile.json", "selectKey", msg.keys);
|
||||
}
|
||||
}
|
||||
validatedIpcMain.on('kylinide.installWizard.init', listenerInit);
|
||||
|
||||
}
|
||||
if (this.DeployWindow) {
|
||||
this.focusWindow(this.DeployWindow);
|
||||
|
|
Loading…
Reference in New Issue