From e5071c88f07f933521e39125cebba7244e94d760 Mon Sep 17 00:00:00 2001 From: Darius Date: Wed, 26 Sep 2018 10:59:08 +0300 Subject: luci-base: cbi.lua: fix TypedSection.parse() It's not necessary to execute all code if section already exists. Signed-off-by: Darius Joksas [reword commit message, squash commits, remove stray semicolon] Signed-off-by: Jo-Philipp Wich --- modules/luci-base/luasrc/cbi.lua | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/modules/luci-base/luasrc/cbi.lua b/modules/luci-base/luasrc/cbi.lua index d275c5b27..971830fe8 100644 --- a/modules/luci-base/luasrc/cbi.lua +++ b/modules/luci-base/luasrc/cbi.lua @@ -1199,19 +1199,20 @@ function TypedSection.parse(self, novld) if name then -- Ignore if it already exists if self:cfgvalue(name) then - name = nil; - end - - name = self:checkscope(name) - - if not name then + name = nil self.err_invalid = true - end + else + name = self:checkscope(name) + + if not name then + self.err_invalid = true + end - if name and #name > 0 then - created = self:create(name, origin) and name - if not created then - self.invalid_cts = true + if name and #name > 0 then + created = self:create(name, origin) and name + if not created then + self.invalid_cts = true + end end end end -- cgit v1.2.3