luci-base: cbi.lua: fix TypedSection.parse()
authorDarius <darius.joksas@teltonika.lt>
Wed, 26 Sep 2018 07:59:08 +0000 (10:59 +0300)
committerJo-Philipp Wich <jo@mein.io>
Sat, 29 Sep 2018 12:01:49 +0000 (14:01 +0200)
It's not necessary to execute all code if section already exists.

Signed-off-by: Darius Joksas <jok.darius@gmail.com>
[reword commit message, squash commits, remove stray semicolon]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/luasrc/cbi.lua

index d275c5b27564366041a56fc3010b07d4a938e8dc..971830fe81c4989c4907edd61b78873dbe3ef530 100644 (file)
@@ -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