X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=libs%2Fcore%2Fluasrc%2Fccache.lua;h=56ccbc3efe30a85bfb15544818ad0d49a0ad840f;hp=437d385256e915df4384f8b46b2c876d3f34dd2a;hb=d4987d7863baf1071d2c1579c8730cf44538fd45;hpb=40d4e839eff49bc2390537d465c4543105e95f59 diff --git a/libs/core/luasrc/ccache.lua b/libs/core/luasrc/ccache.lua index 437d38525..56ccbc3ef 100644 --- a/libs/core/luasrc/ccache.lua +++ b/libs/core/luasrc/ccache.lua @@ -14,8 +14,9 @@ $Id$ ]]-- local io = require "io" +local fs = require "nixio.fs" local util = require "luci.util" -local posix = require "posix" +local nixio = require "nixio" local debug = require "debug" local string = require "string" local package = require "package" @@ -32,14 +33,14 @@ function cache_ondemand(...) end function cache_enable(cachepath, mode) - cachepath = cachepath or "/tmp/.luciccache" + cachepath = cachepath or "/tmp/luci-modulecache" mode = mode or "r--r--r--" local loader = package.loaders[2] - local uid = posix.getpid("uid") + local uid = nixio.getuid() - if not posix.stat(cachepath) then - posix.mkdir(cachepath) + if not fs.stat(cachepath) then + fs.mkdir(cachepath) end local function _encode_filename(name) @@ -51,19 +52,19 @@ function cache_enable(cachepath, mode) end local function _load_sane(file) - local stat = posix.stat(file) - if stat and stat.uid == uid and stat.mode == mode then + local stat = fs.stat(file) + if stat and stat.uid == uid and stat.modestr == mode then return loadfile(file) end end local function _write_sane(file, func) - if posix.getpid("uid") == uid then + if nixio.getuid() == uid then local fp = io.open(file, "w") if fp then fp:write(util.get_bytecode(func)) fp:close() - posix.chmod(file, mode) + fs.chmod(file, mode) end end end