summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-admin-full/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-mod-admin-full/luasrc')
-rw-r--r--modules/luci-mod-admin-full/luasrc/controller/admin/system.lua14
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm5
2 files changed, 15 insertions, 4 deletions
diff --git a/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua b/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua
index 0c19893cf8..153615b58a 100644
--- a/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua
+++ b/modules/luci-mod-admin-full/luasrc/controller/admin/system.lua
@@ -341,9 +341,17 @@ function action_restore()
local upload = http.formvalue("archive")
if upload and #upload > 0 then
- luci.template.render("admin_system/applyreboot")
- os.execute("tar -C / -xzf %q >/dev/null 2>&1" % archive_tmp)
- luci.sys.reboot()
+ if os.execute("gunzip -t %q >/dev/null 2>&1" % archive_tmp) == 0 then
+ luci.template.render("admin_system/applyreboot")
+ os.execute("tar -C / -xzf %q >/dev/null 2>&1" % archive_tmp)
+ luci.sys.reboot()
+ else
+ luci.template.render("admin_system/flashops", {
+ reset_avail = supports_reset(),
+ upgrade_avail = supports_sysupgrade(),
+ backup_invalid = true
+ })
+ end
return
end
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm b/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm
index 0a4bc6578c..f90a6f5424 100644
--- a/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_system/flashops.htm
@@ -50,9 +50,12 @@
</div>
</div>
</form>
+ <% if backup_invalid then %>
+ <div class="cbi-section-error"><%:The backup archive does not appear to be a valid gzip file.%></div>
+ <% end %>
</div>
<% if reset_avail then %>
- <div class="alert-message warning"><%:Custom files (certificates, scripts) may remain on the system. To prevent this, perform a factory-reset first.%></div>
+ <div class="alert-message warning"><%:Custom files (certificates, scripts) may remain on the system. To prevent this, perform a factory-reset first.%></div>
<% end %>
</div>