config_tools: delete the old board file when the new board file is imported successfully.

delete the old board file when the new board file is imported successfully.

Tracked-On: #6691
Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
This commit is contained in:
Weiyi Feng 2022-06-06 16:59:30 +08:00 committed by acrnsi-robot
parent f5d3d71526
commit d93b773755

View File

@ -132,24 +132,22 @@ export default {
let filepath = ''
if (useNewFile) {
filepath = this.newFilePath
if (filepath !== this.currentSelectedBoard) {
configurator.removeFile(this.currentSelectedBoard)
.catch((err) => alert(`${err}`))
}
} else {
filepath = this.currentSelectedBoard
}
if (filepath.length > 0) {
configurator.loadBoard(filepath)
.then(({scenarioJSONSchema, boardInfo}) => {
.then(async ({scenarioJSONSchema, boardInfo}) => {
this.$emit('boardUpdate', boardInfo, scenarioJSONSchema);
let boardFileNewPath = this.WorkingFolder + boardInfo.name;
// Todo: use rust command writeBoard to fix bugs.
if (useNewFile && filepath !== this.currentSelectedBoard) {
await configurator.removeFile(this.currentSelectedBoard)
}
configurator.writeFile(boardFileNewPath, boardInfo.content)
.then(() => configurator.addHistory('Board', boardFileNewPath))
.then(() => this.getBoardHistory())
.then(()=>{
if(!!window.boardUpdate){
.then(() => {
if (!!window.boardUpdate) {
window.boardUpdate(boardInfo)
}
})