- for i,c in ipairs(controllers) do
- c = "luci.controller." .. c:sub(#path+1, #c-#suffix):gsub("/", ".")
- stat, mod = pcall(require, c)
-
- if stat and mod and type(mod.index) == "function" then
- index[c] = mod.index
+ if not cachetime or luci.fs.mtime(path) > cachetime then
+ for i,c in ipairs(controllers) do
+ c = "luci.controller." .. c:sub(#path+1, #c-#suffix):gsub("/", ".")
+ stat, mod = pcall(require, c)
+
+ if stat and mod and type(mod.index) == "function" then
+ index[c] = mod.index
+
+ if indexcache then
+ luci.fs.writefile(indexcache .. "/" .. c, string.dump(mod.index))
+ end
+ end
+ end
+ if indexcache then
+ luci.fs.unlink(indexcache .. "/.index")
+ luci.fs.writefile(indexcache .. "/.index", "")
+ end
+ else
+ for i,c in ipairs(luci.fs.dir(indexcache)) do
+ if c:sub(1) ~= "." then
+ index[c] = loadfile(indexcache .. "/" .. c)
+ end