modules/admin-{mini,full}: start sysupgrade in background
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 27 Mar 2010 02:01:36 +0000 (02:01 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 27 Mar 2010 02:01:36 +0000 (02:01 +0000)
modules/admin-full/luasrc/controller/admin/system.lua
modules/admin-mini/luasrc/controller/mini/system.lua

index 432d803b25cf290d79a3ef0120e9914b9dbcce2d..d420b242745acc43c61e9faeae42865472284c16 100644 (file)
@@ -270,21 +270,15 @@ function action_upgrade()
                if has_platform and has_image and has_support then
                        -- Mimetype text/plain
                        luci.http.prepare_content("text/plain")
+                       luci.http.write("Starting luci-flash...\n")
 
                        -- Now invoke sysupgrade
                        local keepcfg = keep_avail and luci.http.formvalue("keepcfg") == "1"
-                       local fd = io.popen("/sbin/luci-flash %s %q" %{
+                       local flash = ltn12_popen("/sbin/luci-flash %s %q" %{
                                keepcfg and "-k %q" % _keep_pattern() or "", tmpfile
                        })
 
-                       if fd then
-                               while true do
-                                       local ln = fd:read("*l")
-                                       if not ln then break end
-                                       luci.http.write(ln .. "\n")
-                               end
-                               fd:close()
-                       end
+                       luci.ltn12.pump.all(flash, luci.http.write)
 
                        -- Make sure the device is rebooted
                        luci.sys.reboot()
index 93f113a329ffb07a1399466ff4317aa072b178f8..44d0688f6dcfcd4ad9d2d074b87ddc4c42182749 100644 (file)
@@ -151,21 +151,15 @@ function action_upgrade()
                if has_platform and has_image and has_support then
                        -- Mimetype text/plain
                        luci.http.prepare_content("text/plain")
+                       luci.http.write("Starting luci-flash...\n")
 
                        -- Now invoke sysupgrade
                        local keepcfg = keep_avail and luci.http.formvalue("keepcfg") == "1"
-                       local fd = io.popen("/sbin/luci-flash %s %q" %{
+                       local flash = ltn12_popen("/sbin/luci-flash %s %q" %{
                                keepcfg and "-k %q" % _keep_pattern() or "", tmpfile
                        })
 
-                       if fd then
-                               while true do
-                                       local ln = fd:read("*l")
-                                       if not ln then break end
-                                       luci.http.write(ln .. "\n")
-                               end
-                               fd:close()
-                       end
+                       luci.ltn12.pump.all(flash, luci.http.write)
 
                        -- Make sure the device is rebooted
                        luci.sys.reboot()