Skip to content

Commit

Permalink
flash: fail when target config couldn't be fetched
Browse files Browse the repository at this point in the history
  • Loading branch information
bkleiner committed Sep 17, 2023
1 parent e444672 commit f24be04
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
7 changes: 6 additions & 1 deletion src/store/flash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ export const useFlashStore = defineStore("flash", {
},
fetchRuntimeConfig(target: string) {
return fetch(TARGET_URL + target + ".yaml")
.then((res) => res.text())
.then((res) => {
if (!res.ok) {
return Promise.reject(res);
}
return res.text();
})
.then((res) => YAML.parse(res))
.then((target) => CBOR.encode(target));
},
Expand Down
23 changes: 13 additions & 10 deletions src/views/Flash.vue
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export default defineComponent({
{ value: "branch", text: "Development Branch" },
{ value: "local", text: "Local" },
],
progress: {},
progress: [] as any[],
source: "release",
release: undefined as string | undefined,
branch: undefined as string | undefined,
Expand Down Expand Up @@ -443,14 +443,17 @@ export default defineComponent({
const flasher = new Flasher();
flasher.onProgress((p) => this.updateProgress(p));
this.updateProgress({
task: "download",
current: 10,
total: 100,
});
return Promise.all([this.fetchFirmware(), flasher.connect()])
.then(async ([hexStr]) => {
return flasher
.connect()
.then(() => {
this.updateProgress({
task: "download",
current: 10,
total: 100,
});
return this.fetchFirmware();
})
.then(async (hexStr) => {
if (!hexStr) {
throw new Error("firmware not found");
}
Expand Down Expand Up @@ -492,7 +495,7 @@ export default defineComponent({
});
})
.finally(() => {
this.progress = {};
this.progress = [];
this.loading = false;
});
},
Expand Down

0 comments on commit f24be04

Please sign in to comment.