luci-base: fix some minor luci.model.uci issues
- Properly serialize option delete changelogs - Do not perform a section create if a nil value is passed to set() Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
4cd08258bb
commit
7be3f0400c
1 changed files with 5 additions and 5 deletions
|
@ -8,7 +8,7 @@ local table = require "table"
|
||||||
|
|
||||||
local setmetatable, rawget, rawset = setmetatable, rawget, rawset
|
local setmetatable, rawget, rawset = setmetatable, rawget, rawset
|
||||||
local require, getmetatable, assert = require, getmetatable, assert
|
local require, getmetatable, assert = require, getmetatable, assert
|
||||||
local error, pairs, ipairs = error, pairs, ipairs
|
local error, pairs, ipairs, select = error, pairs, ipairs, select
|
||||||
local type, tostring, tonumber, unpack = type, tostring, tonumber, unpack
|
local type, tostring, tonumber, unpack = type, tostring, tonumber, unpack
|
||||||
|
|
||||||
-- The typical workflow for UCI is: Get a cursor instance from the
|
-- The typical workflow for UCI is: Get a cursor instance from the
|
||||||
|
@ -106,7 +106,7 @@ function changes(self, config)
|
||||||
local _, change
|
local _, change
|
||||||
for _, change in ipairs(changes) do
|
for _, change in ipairs(changes) do
|
||||||
local operation, section, option, value = unpack(change)
|
local operation, section, option, value = unpack(change)
|
||||||
if option and value and operation ~= "add" then
|
if option and operation ~= "add" then
|
||||||
res[package][section] = res[package][section] or { }
|
res[package][section] = res[package][section] or { }
|
||||||
|
|
||||||
if operation == "list-add" then
|
if operation == "list-add" then
|
||||||
|
@ -373,15 +373,15 @@ function add(self, config, stype)
|
||||||
return self:section(config, stype)
|
return self:section(config, stype)
|
||||||
end
|
end
|
||||||
|
|
||||||
function set(self, config, section, option, value)
|
function set(self, config, section, option, ...)
|
||||||
if value == nil then
|
if select('#', ...) == 0 then
|
||||||
local sname, err = self:section(config, option, section)
|
local sname, err = self:section(config, option, section)
|
||||||
return (not not sname), err
|
return (not not sname), err
|
||||||
else
|
else
|
||||||
local _, err = call("set", {
|
local _, err = call("set", {
|
||||||
config = config,
|
config = config,
|
||||||
section = section,
|
section = section,
|
||||||
values = { [option] = value }
|
values = { [option] = select(1, ...) }
|
||||||
})
|
})
|
||||||
return (err == nil), ERRSTR[err]
|
return (err == nil), ERRSTR[err]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue