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 = '' let filepath = ''
if (useNewFile) { if (useNewFile) {
filepath = this.newFilePath filepath = this.newFilePath
if (filepath !== this.currentSelectedBoard) {
configurator.removeFile(this.currentSelectedBoard)
.catch((err) => alert(`${err}`))
}
} else { } else {
filepath = this.currentSelectedBoard filepath = this.currentSelectedBoard
} }
if (filepath.length > 0) { if (filepath.length > 0) {
configurator.loadBoard(filepath) configurator.loadBoard(filepath)
.then(({scenarioJSONSchema, boardInfo}) => { .then(async ({scenarioJSONSchema, boardInfo}) => {
this.$emit('boardUpdate', boardInfo, scenarioJSONSchema); this.$emit('boardUpdate', boardInfo, scenarioJSONSchema);
let boardFileNewPath = this.WorkingFolder + boardInfo.name; 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) configurator.writeFile(boardFileNewPath, boardInfo.content)
.then(() => configurator.addHistory('Board', boardFileNewPath)) .then(() => configurator.addHistory('Board', boardFileNewPath))
.then(() => this.getBoardHistory()) .then(() => this.getBoardHistory())
.then(()=>{ .then(() => {
if(!!window.boardUpdate){ if (!!window.boardUpdate) {
window.boardUpdate(boardInfo) window.boardUpdate(boardInfo)
} }
}) })