From 9093b48ab4078244b942d76110e3f1da51e4b77a Mon Sep 17 00:00:00 2001 From: sajolida Date: Tue, 8 Dec 2020 01:02:49 +0000 Subject: [PATCH] Catch error when file is null or undefined --- wiki/src/install/inc/js/download.js | 15 +++++++++++++-- wiki/src/install/inc/steps/download.inline.html | 6 ++++++ wiki/src/install/inc/stylesheets/download.css | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/wiki/src/install/inc/js/download.js b/wiki/src/install/inc/js/download.js index 9171bdd335..e253a2d8a3 100644 --- a/wiki/src/install/inc/js/download.js +++ b/wiki/src/install/inc/js/download.js @@ -116,6 +116,9 @@ document.addEventListener("DOMContentLoaded", function() { else if (result === "failed-again") { show(document.getElementById("verification-failed-again")); } + else if (result === "error-file") { + show(document.getElementById("verification-error-file")); + } else if (result === "error-json") { show(document.getElementById("verification-error-json")); document.getElementById("checksum-file").setAttribute("href", URLofJsonFileContainingChecksums); @@ -131,6 +134,7 @@ document.addEventListener("DOMContentLoaded", function() { hide(document.getElementById("verification-successful")); hide(document.getElementById("verification-failed")); hide(document.getElementById("verification-failed-again")); + hide(document.getElementById("verification-error-file")); hide(document.getElementById("verification-error-json")); hide(document.getElementById("verification-error-image")); show(document.getElementById("verification")); @@ -147,8 +151,14 @@ document.addEventListener("DOMContentLoaded", function() { /* Verification logic functions */ async function verifyFile(e, elm) { - file = elm.files[0] - showVerifyingDownload(file.name); + + try { + file = elm.files[0]; + showVerifyingDownload(file.name); + } catch(err) { + showVerificationResult("error-file"); + return; + } try { var response=await fetch(URLofJsonFileContainingChecksums); @@ -306,5 +316,6 @@ document.addEventListener("DOMContentLoaded", function() { // showVerificationResult("failed-again"); // showVerificationResult("error-json"); // showVerificationResult("error-image"); + // verifyFile(null, null); }); diff --git a/wiki/src/install/inc/steps/download.inline.html b/wiki/src/install/inc/steps/download.inline.html index 8bf6498634..c5f2ec3910 100644 --- a/wiki/src/install/inc/steps/download.inline.html +++ b/wiki/src/install/inc/steps/download.inline.html @@ -145,6 +145,12 @@ were solved, and known issues that have already been identified.

Please try to download again from a different place or a different computer…

+
+

[[!img lib/cross.png class="icon" link="no" alt=""]]Error selecting image.

+

Make sure that you select a USB image that is readable by your browser.

+

Make sure that you select an ISO image that is readable by your browser.

+

Retry…

+

[[!img lib/cross.png class="icon" link="no" alt=""]]Error downloading checksum file from our website.

Make sure that your browser is connected to the Internet.

diff --git a/wiki/src/install/inc/stylesheets/download.css b/wiki/src/install/inc/stylesheets/download.css index 296df4e603..e2d98d0c2a 100644 --- a/wiki/src/install/inc/stylesheets/download.css +++ b/wiki/src/install/inc/stylesheets/download.css @@ -18,6 +18,7 @@ #verification-successful, #verification-failed, #verification-failed-again, +#verification-error-file, #verification-error-json, #verification-error-image, #skip-download, @@ -147,7 +148,7 @@ img.icon { vertical-align: bottom; } -#verification-error-json, #verification-error-image { +#verification-error-file, #verification-error-json, #verification-error-image { margin-top: 1.5em; } -- GitLab