From f311d13ca16e079e6e9c68bc1c62fb6e94400ee5 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 31 Jul 2009 00:13:24 +0000 Subject: [PATCH] libs/cbi: fix error reporting in map loading --- libs/cbi/luasrc/cbi.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index db76e3b92..83f5c27e7 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -60,17 +60,18 @@ function load(cbimap, ...) local upldir = "/lib/uci/upload/" local cbidir = luci.util.libpath() .. "/model/cbi/" - - assert(fs.stat(cbimap) or - fs.stat(cbidir..cbimap..".lua") or - fs.stat(cbidir..cbimap..".lua.gz"), - "Model not found!") - - local func, err = loadfile(cbimap) - if not func then - func, err = loadfile(cbidir..cbimap..".lua") or - loadfile(cbidir..cbimap..".lua.gz") + local func, err + + if fs.access(cbimap) then + func, err = loadfile(cbimap) + elseif fs.access(cbidir..cbimap..".lua") then + func, err = loadfile(cbidir..cbimap..".lua") + elseif fs.access(cbidir..cbimap..".lua.gz") then + func, err = loadfile(cbidir..cbimap..".lua.gz") + else + func, err = nil, "Model '" .. cbimap .. "' not found!" end + assert(func, err) luci.i18n.loadc("cbi") -- 2.25.1