* Fixed apply function

* Fixed a few typos
This commit is contained in:
Steven Barth 2008-05-06 16:31:16 +00:00
parent 4ce666845f
commit 21bd8ca76d
3 changed files with 16 additions and 12 deletions

View file

@ -31,7 +31,7 @@ FORM = FORM or {}
-- HTTP interface -- HTTP interface
-- Returns a table of all COOKIE, GET and POST Parameters -- Returns a table of all COOKIE, GET and POST Parameters
function ffluci.http.formvalues(prefix) function ffluci.http.formvalues()
return FORM return FORM
end end

View file

@ -28,7 +28,7 @@ module("ffluci.sgi.webuci", package.seeall)
-- HTTP interface -- HTTP interface
-- Returns a table of all COOKIE, GET and POST Parameters -- Returns a table of all COOKIE, GET and POST Parameters
function ffluci.http.formvalues(prefix) function ffluci.http.formvalues()
return webuci.vars return webuci.vars
end end

View file

@ -8,25 +8,29 @@ function action_apply()
local output = "" local output = ""
if changes then if changes then
local apply = {} local com = {}
local run = {}
-- Collect files to be applied and commit changes -- Collect files to be applied and commit changes
for i, line in ipairs(ffluci.util.split(changes)) do for i, line in ipairs(ffluci.util.split(changes)) do
local r = line:match("^-?([^.]+)") local r = line:match("^-?([^.]+)")
if r and not ffluci.util.contains(apply, ffluci.config.uci_oncommit[r]) then if r then
table.insert(apply, ffluci.config.uci_oncommit[r]) com[r] = true
ffluci.model.uci.commit(r)
if ffluci.config.uci_oncommit and ffluci.config.uci_oncommit[r] then
run[ffluci.config.uci_oncommit[r]] = true
end
end end
end end
-- Apply
for config, i in pairs(com) do
ffluci.model.uci.commit(config)
end
-- Search for post-commit commands -- Search for post-commit commands
if ffluci.config.uci_oncommit then for cmd, i in pairs(run) do
for i, cmd in ipairs(apply) do output = output .. cmd .. ":" .. ffluci.sys.exec(cmd) .. "\n"
if cmd then
output = output .. cmd .. ":" .. ffluci.sys.exec(cmd) .. "\n"
end
end
end end
end end