diff mbox series

[OpenWrt-Devel,luci,2/2] luci-mod-system: check if it's possible to force sysupgrade

Message ID 20190925145138.6185-2-zajec5@gmail.com
State Accepted
Headers show
Series [OpenWrt-Devel,luci,1/2] luci-mod-system: use "system" new "validate_firmware_image" ubus method | expand

Commit Message

Rafał Miłecki Sept. 25, 2019, 2:51 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

Some validation errors may be critical enough to prevent sysupgrade.
Check the "forceable" property and disallow forcing sysupgrade if
applicable. It would fail anyway at the "sysupgrade" call.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 .../htdocs/luci-static/resources/view/system/flash.js          | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js
index 784ec135b..1349fecd4 100644
--- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js
+++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js
@@ -362,6 +362,7 @@  return L.view.extend({
 				var keep = document.querySelector('[data-name="keep"] input[type="checkbox"]'),
 				    force = E('input', { type: 'checkbox' }),
 				    is_valid = res[1].valid,
+				    is_forceable = res[1].forceable,
 				    is_too_big = (storage_size > 0 && res[0].size > storage_size),
 				    body = [];
 
@@ -389,7 +390,7 @@  return L.view.extend({
 						_('The uploaded image file does not contain a supported format. Make sure that you choose the generic image format for your platform.')
 					]));
 
-				if (!is_valid || is_too_big)
+				if ((!is_valid || is_too_big) && is_forceable)
 					body.push(E('p', {}, E('label', { 'class': 'btn alert-message danger' }, [
 						force, ' ', _('Force upgrade'),
 						E('br'), E('br'),