mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-08 05:04:21 +08:00
🎉 Sync 2026-10-13 02:34:41
This commit is contained in:
1 parent
b537a62e59
commit
72c44a6325
38 files changed
+3510
-1734
No files matched your search
@@ -871,19 +871,26 @@ function clone(org)
|
||||
end
|
||||
|
||||
function get_bin_version_cache(file, cmd)
|
||||
sys.call("mkdir -p " .. CACHE_PATH)
|
||||
if fs.access(file) then
|
||||
if file and file ~= "" and fs.access(file) then
|
||||
chmod_755(file)
|
||||
local md5 = md5_file(file)
|
||||
if fs.access(CACHE_PATH .. "/" .. md5) then
|
||||
return sys.exec("echo -n $(cat %s)" % { CACHE_PATH .. "/" .. md5 })
|
||||
else
|
||||
local version = sys.exec(string.format("echo -n $(%s %s)", file, cmd))
|
||||
if version and version ~= "" then
|
||||
sys.call("echo '%s' > %s" % { version, CACHE_PATH .. "/" .. md5})
|
||||
return version
|
||||
local stat = fs.stat(file)
|
||||
local cache_file
|
||||
if stat and stat.dev and stat.ino and stat.size and stat.mtime and stat.ctime then
|
||||
-- Use metadata to avoid hashing the entire binary on every lookup.
|
||||
cache_file = CACHE_PATH .. "/binver_" .. table.concat({stat.dev, stat.ino, stat.size, stat.mtime, stat.ctime}, "_")
|
||||
local cached = fs.readfile(cache_file)
|
||||
if cached and trim(cached) ~= "" then
|
||||
return trim(cached)
|
||||
end
|
||||
end
|
||||
local version = sys.exec(string.format("echo -n $(%s %s)", util.shellquote(file), cmd))
|
||||
if version and version ~= "" then
|
||||
if cache_file then
|
||||
fs.mkdirr(CACHE_PATH)
|
||||
fs.writefile(cache_file, version)
|
||||
end
|
||||
return version
|
||||
end
|
||||
end
|
||||
return ""
|
||||
end
|
||||
@@ -904,7 +911,7 @@ end
|
||||
|
||||
local function is_file(path)
|
||||
if path and #path > 1 then
|
||||
if sys.exec('[ -f "%s" ] && echo -n 1' % path) == "1" then
|
||||
if fs.stat(path, "type") == "reg" then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -913,7 +920,7 @@ end
|
||||
|
||||
local function is_dir(path)
|
||||
if path and #path > 1 then
|
||||
if sys.exec('[ -d "%s" ] && echo -n 1' % path) == "1" then
|
||||
if fs.stat(path, "type") == "dir" then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -1554,7 +1561,7 @@ function to_install_self(id, force)
|
||||
remove(dir)
|
||||
return {code = 1}
|
||||
end
|
||||
fs.chmod(script, 755)
|
||||
chmod_755(script)
|
||||
fs.writefile(status, '{"installing":true}')
|
||||
sys.call("nohup " .. script .. " " .. dir .. " " .. status .. " " .. manager .. " " ..
|
||||
(force == "1" and "1" or "0") .. " >/dev/null 2>&1 </dev/null &")
|
||||
@@ -1562,7 +1569,7 @@ function to_install_self(id, force)
|
||||
end
|
||||
|
||||
function is_js_luci()
|
||||
return sys.call('[ -f "/www/luci-static/resources/uci.js" ]') == 0
|
||||
return fs.stat("/www/luci-static/resources/uci.js", "type") == "reg"
|
||||
end
|
||||
|
||||
function set_default_cbi()
|
||||
@@ -1614,6 +1621,16 @@ function set_default_cbi()
|
||||
return obj
|
||||
end
|
||||
end
|
||||
if true then
|
||||
--Table
|
||||
local Table = cbi.Table
|
||||
local default_init = Table.__init__
|
||||
function Table.__init__(self, form, ...)
|
||||
default_init(self, form, ...)
|
||||
-- Table 的 map 是独立数据源,需要从所属表单传递 API
|
||||
self.map.api = form.api
|
||||
end
|
||||
end
|
||||
if true then
|
||||
--TextValue
|
||||
local TextValue = cbi.TextValue
|
||||
|
||||
Reference in new issue
Block a user