projects
/
project
/
luci.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* luci/libs/uvl: fix an error message in luci.uvl.read_scheme()
[project/luci.git]
/
libs
/
uvl
/
luasrc
/
uvl.lua
diff --git
a/libs/uvl/luasrc/uvl.lua
b/libs/uvl/luasrc/uvl.lua
index
007a37d
..
aada2e6
100644
(file)
--- a/
libs/uvl/luasrc/uvl.lua
+++ b/
libs/uvl/luasrc/uvl.lua
@@
-321,7
+321,7
@@
function UVL._validate_option( self, option, nodeps )
for i, v in ipairs(val) do
if not self.datatypes[dt]( v ) then
return false, option:error(
for i, v in ipairs(val) do
if not self.datatypes[dt]( v ) then
return false, option:error(
- ERR.OPT_INVVALUE(option,
dt
)
+ ERR.OPT_INVVALUE(option,
{ v, dt }
)
)
end
end
)
end
end
@@
-351,33
+351,47
@@
end
-- This is normally done on demand, so you don't have to call this function
-- by yourself.
-- @param scheme Name of the scheme to parse
-- This is normally done on demand, so you don't have to call this function
-- by yourself.
-- @param scheme Name of the scheme to parse
-function UVL.read_scheme( self, scheme )
+-- @param alias Create an alias for the loaded scheme
+function UVL.read_scheme( self, scheme, alias )
local so = luci.uvl.scheme( self, scheme )
local so = luci.uvl.scheme( self, scheme )
+ local bc = "%s/bytecode/%s.lua" %{ self.schemedir, scheme }
- local schemes = { }
- local files = luci.fs.glob(self.schemedir .. '/*/' .. scheme)
+ if not luci.fs.access(bc) then
+ local schemes = { }
+ local files = luci.fs.glob(self.schemedir .. '/*/' .. scheme)
- if files then
- for i, file in ipairs( files ) do
- if not luci.fs.access(file) then
-
return
so:error(ERR.SME_READ(so,file))
- end
+
if files then
+
for i, file in ipairs( files ) do
+
if not luci.fs.access(file) then
+
return false,
so:error(ERR.SME_READ(so,file))
+
end
- local uci = luci.model.uci.cursor( luci.fs.dirname(file), default_savedir )
+
local uci = luci.model.uci.cursor( luci.fs.dirname(file), default_savedir )
- local sd, err = uci:get_all( luci.fs.basename(file) )
+ local sd, err = uci:get_all( luci.fs.basename(file) )
+
+ if not sd then
+ return false, ERR.UCILOAD(so, err)
+ end
- if not sd then
- return false, ERR.UCILOAD(so, err)
+ table.insert( schemes, sd )
end
end
- table.insert( schemes, sd )
+ local ok, err = self:_read_scheme_parts( so, schemes )
+ if ok and alias then self.packages[alias] = self.packages[scheme] end
+ return ok, err
+ else
+ return false, so:error(ERR.SME_FIND(so, self.schemedir))
end
end
-
- return self:_read_scheme_parts( so, schemes )
else
else
- return false, so:error(ERR.SME_FIND(so, self.schemedir))
+ local sc = loadfile(bc)
+ if sc then
+ self.packages[scheme] = sc()
+ return true
+ else
+ return false, so:error(ERR.SME_READ(so,bc))
+ end
end
end
end
end