summaryrefslogtreecommitdiffhomepage
path: root/libs/web
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-06-02 15:36:13 +0000
committerSteven Barth <steven@midlink.org>2008-06-02 15:36:13 +0000
commit08e85e726c16b996ceea429f35c37ca40ac6d777 (patch)
tree233d69897e9a602ccb17a58348a84e34c6be8c74 /libs/web
parentfbe3f6f09fe7147c08b15ca45533c685930f28f9 (diff)
* Reintegrated fastindex support
Diffstat (limited to 'libs/web')
-rw-r--r--libs/web/luasrc/dispatcher.lua25
1 files changed, 17 insertions, 8 deletions
diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua
index c867579d2..feda28d51 100644
--- a/libs/web/luasrc/dispatcher.lua
+++ b/libs/web/luasrc/dispatcher.lua
@@ -49,6 +49,9 @@ dispatched = nil
built_index = false
built_tree = false
+-- Fastindex
+local fi
+
-- Builds a URL
function build_url(...)
@@ -157,22 +160,22 @@ function createindex()
local path = luci.sys.libpath() .. "/controller/"
local suff = ".lua"
- --[[if pcall(require, "fastindex") then
+ if pcall(require, "luci.fastindex") then
createindex_fastindex(path, suff)
else
createindex_plain(path, suff)
- end]]--
-
- createindex_plain(path, suff)
+ end
built_index = true
end
-- Uses fastindex to create the dispatching tree
function createindex_fastindex(path, suffix)
- local fi = fastindex.new("index")
- fi.add(path .. "*" .. suffix)
- fi.add(path .. "*/*" .. suffix)
+ if not fi then
+ fi = luci.fastindex.new("index")
+ fi.add(path .. "*" .. suffix)
+ fi.add(path .. "*/*" .. suffix)
+ end
fi.scan()
for k, v in pairs(fi.indexes) do
@@ -181,7 +184,12 @@ function createindex_fastindex(path, suffix)
end
-- Calls the index function of all available controllers
+-- Fallback for transition purposes / Leave it in as long as it works otherwise throw it away
function createindex_plain(path, suffix)
+ if built_index then
+ return
+ end
+
local cache = nil
local controllers = luci.util.combine(
@@ -201,11 +209,12 @@ function createindex_plain(path, suffix)
for i,c in ipairs(controllers) do
local module = "luci.controller." .. c:sub(#path+1, #c-#suffix):gsub("/", ".")
- local cachefile = indexcache .. "/" .. module
+ local cachefile
local stime
local ctime
if cache then
+ cachefile = indexcache .. "/" .. module
stime = luci.fs.mtime(c) or 0
ctime = luci.fs.mtime(cachefile) or 0
end