luci-app-attendedsysupgrade: add more robust handling of downloads
authorEric Fahlgren <[email protected]>
Wed, 19 Mar 2025 21:15:04 +0000 (14:15 -0700)
committerPaul Donald <[email protected]>
Fri, 21 Mar 2025 13:32:40 +0000 (14:32 +0100)
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 <[email protected]>
(cherry picked from commit 51a8f8cd229cb95deb607422a43d570d2d90980e)

applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js

index c136e8f96ba25874ff2fca2cd02cbb55fd26356e..84cc0f1aa5def157e4299baf5e877b24499c4879 100644 (file)
@@ -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:<br>${overview_url}<br>${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:<br>${revision_url}<br>${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();
                                                                                        });
                                                                                });
                                                                        }),