mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-23 05:57:33 +00:00
config-tools: fix bug for saving files
The clean scripts function is a async function, it may run after saving launch scripts and remove all the launch scripts by accident. So, add '.then' to make it work as a sync function. Tracked-On: #7641 Signed-off-by: Conghui <conghui.chen@intel.com>
This commit is contained in:
parent
f6f8a23df1
commit
1b7e8e393f
@ -276,7 +276,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
cleanLaunchScript() {
|
cleanLaunchScript() {
|
||||||
configurator.readDir(this.WorkingFolder, false)
|
return configurator.readDir(this.WorkingFolder, false)
|
||||||
.then((files) => {
|
.then((files) => {
|
||||||
if (files.length > 0) {
|
if (files.length > 0) {
|
||||||
for (let i = 0; i < files.length; i++) {
|
for (let i = 0; i < files.length; i++) {
|
||||||
@ -382,6 +382,7 @@ export default {
|
|||||||
}
|
}
|
||||||
let errorFlag = false
|
let errorFlag = false
|
||||||
errorFlag = this.confirmVmName()
|
errorFlag = this.confirmVmName()
|
||||||
|
if (errorFlag) {return}
|
||||||
this.assignVMID()
|
this.assignVMID()
|
||||||
let msg = [
|
let msg = [
|
||||||
"scenario xml saved\n",
|
"scenario xml saved\n",
|
||||||
@ -411,11 +412,10 @@ export default {
|
|||||||
totalMsg = totalMsg - 1 // remove the 'launch script' related mssage.
|
totalMsg = totalMsg - 1 // remove the 'launch script' related mssage.
|
||||||
}
|
}
|
||||||
// begin write down and verify
|
// begin write down and verify
|
||||||
try {
|
|
||||||
configurator.writeFile(this.WorkingFolder + 'scenario.xml', scenarioXMLData)
|
configurator.writeFile(this.WorkingFolder + 'scenario.xml', scenarioXMLData)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
stepDone = 1
|
stepDone = 1
|
||||||
if (!errorFlag) {
|
|
||||||
console.log("validate settings...")
|
console.log("validate settings...")
|
||||||
this.errors = configurator.pythonObject.validateScenario(this.board.content, scenarioXMLData)
|
this.errors = configurator.pythonObject.validateScenario(this.board.content, scenarioXMLData)
|
||||||
// noinspection ExceptionCaughtLocallyJS
|
// noinspection ExceptionCaughtLocallyJS
|
||||||
@ -424,21 +424,26 @@ export default {
|
|||||||
}
|
}
|
||||||
console.log("validation ok")
|
console.log("validation ok")
|
||||||
stepDone = 2
|
stepDone = 2
|
||||||
this.cleanLaunchScript()
|
return this.cleanLaunchScript()
|
||||||
|
}).then(() => {
|
||||||
if (needSaveLaunchScript) {
|
if (needSaveLaunchScript) {
|
||||||
let launchScripts = configurator.pythonObject.generateLaunchScript(this.board.content, scenarioXMLData)
|
let launchScripts = configurator.pythonObject.generateLaunchScript(this.board.content, scenarioXMLData)
|
||||||
|
let writeDone = []
|
||||||
for (let filename in launchScripts) {
|
for (let filename in launchScripts) {
|
||||||
configurator.writeFile(this.WorkingFolder + filename, launchScripts[filename])
|
writeDone.push(configurator.writeFile(this.WorkingFolder + filename, launchScripts[filename]))
|
||||||
}
|
}
|
||||||
|
return Promise.all(writeDone)
|
||||||
|
} else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((result) => {
|
||||||
|
if (!_.isEmpty(result)) {
|
||||||
stepDone = 3
|
stepDone = 3
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
alert(`${msg.slice(0, stepDone).join('')} \nAll files successfully saved to your working folder ${this.WorkingFolder}`)
|
alert(`${msg.slice(0, stepDone).join('')} \nAll files successfully saved to your working folder ${this.WorkingFolder}`)
|
||||||
})
|
})
|
||||||
} catch (err) {
|
.catch((err)=>{
|
||||||
console.log("error" + err)
|
console.log("error" + err)
|
||||||
let outmsg = ''
|
let outmsg = ''
|
||||||
for (var i = 0; i < stepDone; i++)
|
for (var i = 0; i < stepDone; i++)
|
||||||
@ -446,10 +451,9 @@ export default {
|
|||||||
for (i = stepDone; i < totalMsg; i++)
|
for (i = stepDone; i < totalMsg; i++)
|
||||||
outmsg += errmsg[i]
|
outmsg += errmsg[i]
|
||||||
alert(`${outmsg} \n Please check your configuration`)
|
alert(`${outmsg} \n Please check your configuration`)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user