diff options
| author | Steven Barth <steven@midlink.org> | 2008-11-09 18:01:19 +0000 |
|---|---|---|
| committer | Steven Barth <steven@midlink.org> | 2008-11-09 18:01:19 +0000 |
| commit | cde0e671a76830767c5438840a431ec9d2e0ff8f (patch) | |
| tree | 757657c5d9e8777c9e7a243cb19cc1fa3cd49723 /libs | |
| parent | 27adbcf125ae7ac971959189495f86b0e7e0ec87 (diff) | |
Ensure hotdeploying
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/web/luasrc/dispatcher.lua | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua index 5afb079785..b0c35d08f4 100644 --- a/libs/web/luasrc/dispatcher.lua +++ b/libs/web/luasrc/dispatcher.lua @@ -299,28 +299,35 @@ end -- @param path Controller base directory -- @param suffix Controller file suffix function createindex_plain(path, suffix) + local controllers = util.combine( + luci.fs.glob(path .. "*" .. suffix) or {}, + luci.fs.glob(path .. "*/*" .. suffix) or {} + ) + if indexcache then local cachedate = fs.mtime(indexcache) - if cachedate and cachedate > fs.mtime(path) then + if cachedate then + local realdate = 0 + for _, obj in ipairs(controllers) do + local omtime = fs.mtime(path .. "/" .. obj) + realdate = (omtime and omtime > realdate) and omtime or realdate + end - assert( - sys.process.info("uid") == fs.stat(indexcache, "uid") - and fs.stat(indexcache, "mode") == "rw-------", - "Fatal: Indexcache is not sane!" - ) + if cachedate > realdate then + assert( + sys.process.info("uid") == fs.stat(indexcache, "uid") + and fs.stat(indexcache, "mode") == "rw-------", + "Fatal: Indexcache is not sane!" + ) - index = loadfile(indexcache)() - return index + index = loadfile(indexcache)() + return index + end end end index = {} - local controllers = util.combine( - luci.fs.glob(path .. "*" .. suffix) or {}, - luci.fs.glob(path .. "*/*" .. suffix) or {} - ) - for i,c in ipairs(controllers) do local module = "luci.controller." .. c:sub(#path+1, #c-#suffix):gsub("/", ".") local mod = require(module) |
