From 51a8f8cd229cb95deb607422a43d570d2d90980e Mon Sep 17 00:00:00 2001 From: Eric Fahlgren Date: Wed, 19 Mar 2025 14:15:04 -0700 Subject: [PATCH] luci-app-attendedsysupgrade: add more robust handling of downloads Check various aspects of the overview and revision downloads from the sysupgrade site, giving the user better error messages when things go wrong. Partially addresses issue #7687 with respect to diagnosis, but not root cause. Signed-off-by: Eric Fahlgren --- .../view/attendedsysupgrade/overview.js | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js b/applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js index c136e8f96b..84cc0f1aa5 100644 --- a/applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js +++ b/applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js @@ -87,23 +87,22 @@ return view.extend({ let changes, target_revision; await Promise.all([ - request.get(overview_url).then( - (response) => { - let json = response.json(); - changes = json.branches[get_branch(version)].package_changes; - }, - (failed) => { - ui.addNotification(null, E('p', _(`Get overview failed ${failed}`))); - } - ), - request.get(revision_url).then( - (response) => { - target_revision = get_revision_count(response.json().revision); - }, - (failed) => { - ui.addNotification(null, E('p', _(`Get revision failed ${failed}`))); - } - ), + request.get(overview_url) + .then(response => response.json()) + .then(json => json.branches) + .then(branches => branches[get_branch(version)]) + .then(branch => { changes = branch.package_changes; }) + .catch(error => { + throw Error(`Get overview failed:
${overview_url}
${error}`); + }), + + request.get(revision_url) + .then(response => response.json()) + .then(json => json.revision) + .then(revision => { target_revision = get_revision_count(revision); }) + .catch(error => { + throw Error(`Get revision failed:
${revision_url}
${error}`); + }), ]); for (const change of changes) { @@ -595,6 +594,10 @@ return view.extend({ }, this); poll.add(this.pollFn, 5); poll.start(); + }) + .catch(error => { + ui.addNotification(null, E('p', error.message)); + ui.hideModal(); }); }); }), -- 2.30.2