From: Jo-Philipp Wich Date: Fri, 31 Jul 2009 00:13:24 +0000 (+0000) Subject: libs/cbi: fix error reporting in map loading X-Git-Tag: 0.10.0~1272 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f311d13ca16e079e6e9c68bc1c62fb6e94400ee5;p=oweals%2Fluci.git libs/cbi: fix error reporting in map loading --- 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")