Broadcom should handle keep_avail now
[project/luci.git] / modules / admin-mini / luasrc / controller / mini / system.lua
index d68283c..ac6d64b 100644 (file)
@@ -79,12 +79,10 @@ end
 function action_upgrade()
        require("luci.model.uci")
 
-       local ret, err
+       local ret  = nil
        local plat = luci.fs.mtime("/lib/upgrade/platform.sh")
        local tmpfile = "/tmp/firmware.img"
-       local broadcom = os.execute('grep brcm_ /lib/upgrade/platform.sh >/dev/null 2>&1') == 0
-        
-       local keep_avail = not broadcom
+       local keep_avail = true
 
        local file
        luci.http.setfilehandler(
@@ -105,11 +103,13 @@ function action_upgrade()
        local keepcfg = keep_avail and luci.http.formvalue("keepcfg")
 
        if plat and fname then
-               ret, err = luci.sys.flash(tmpfile, keepcfg and _keep_pattern())
+               ret = function()
+                       return luci.sys.flash(tmpfile, keepcfg and _keep_pattern())
+               end
        end
 
-       luci.template.render("admin_system/upgrade", {sysupgrade=plat,
-               ret=ret, err=err, keep_avail=keep_avail})
+       luci.http.prepare_content("text/html")
+       luci.template.render("mini/upgrade", {sysupgrade=plat, ret=ret, keep_avail=keep_avail})
 end
 
 function _keep_pattern()
@@ -117,9 +117,11 @@ function _keep_pattern()
        local files = luci.model.uci.cursor():get_all("luci", "flash_keep")
        if files then
                kpattern = ""
-               for k,v in pairs(files) do
-                       kpattern = kpattern .. " " ..  v
+               for k, v in pairs(files) do
+                       if k:sub(1,1) ~= "." and luci.fs.glob(v) then
+                               kpattern = kpattern .. " " ..  v
+                       end
                end
        end
        return kpattern
-end
+end
\ No newline at end of file