lua-simple-uci: fix set()/tset()/section() with empty lists

This commit is contained in:
Matthias Schiffer 2017-10-19 02:11:09 +02:00
parent 81e23cf0c9
commit 6d2b807fba
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
1 changed files with 3 additions and 5 deletions

View File

@ -24,14 +24,15 @@ local Cursor = getmetatable(cursor())
local uciset = Cursor.set
function Cursor:set(config, section, option, value)
if value ~= nil then
if value ~= nil and not (type(value) == 'table' and #value == 0) then
if type(value) == 'boolean' then
value = value and '1' or '0'
end
return uciset(self, config, section, option, value)
else
return self:delete(config, section, option)
self:delete(config, section, option)
return true
end
end
@ -128,9 +129,6 @@ end
function Cursor:set_list(config, section, option, value)
if config and section and option then
if not value or #value == 0 then
return self:delete(config, section, option)
end
return self:set(
config, section, option,
(type(value) == "table" and value or { value })