mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-08 05:04:21 +08:00
🚀 Sync 2026-10-28 01:43:31
This commit is contained in:
1 parent
e646593c56
commit
d42296f292
162 files changed
+356
-233
No files matched your search
@@ -888,7 +888,7 @@ function clone(org)
|
||||
return res
|
||||
end
|
||||
|
||||
function get_bin_version_cache(file, cmd)
|
||||
function get_bin_version_cache(file, cmd, sb_tags)
|
||||
if file and file ~= "" and fs.access(file) then
|
||||
chmod_755(file)
|
||||
local stat = fs.stat(file)
|
||||
@@ -897,16 +897,28 @@ function get_bin_version_cache(file, cmd)
|
||||
-- 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)
|
||||
local version = cached and trim(cached:match("^[^\n]*"))
|
||||
if version and version ~= "" then
|
||||
if sb_tags then
|
||||
return version, trim(cached:match("^[^\n]*\n([^\n]*)"))
|
||||
end
|
||||
return version
|
||||
end
|
||||
end
|
||||
local version = sys.exec(string.format("echo -n $(%s %s)", util.shellquote(file), cmd))
|
||||
local version, tags
|
||||
if sb_tags then
|
||||
local output = sys.exec(string.format("%s %s", util.shellquote(file), cmd))
|
||||
version = output:match("^sing%-box%s+version%s+(%S+)") or ""
|
||||
tags = trim(output:match("\nTags:[ \t]*([^\r\n]*)"))
|
||||
else
|
||||
version = sys.exec(string.format("echo -n $(%s %s)", util.shellquote(file), cmd))
|
||||
end
|
||||
if version and version ~= "" then
|
||||
if cache_file then
|
||||
fs.mkdirr(CACHE_PATH)
|
||||
fs.writefile(cache_file, version)
|
||||
fs.writefile(cache_file, sb_tags and (version .. "\n" .. tags .. "\n") or version)
|
||||
end
|
||||
if sb_tags then return version, tags end
|
||||
return version
|
||||
end
|
||||
end
|
||||
@@ -924,7 +936,14 @@ end
|
||||
|
||||
function get_app_version(app_name, file)
|
||||
if file == nil then file = get_app_path(app_name) end
|
||||
return get_bin_version_cache(file, com[app_name].cmd_version)
|
||||
local version = get_bin_version_cache(file, com[app_name].cmd_version, app_name == "sing-box")
|
||||
return version
|
||||
end
|
||||
|
||||
function get_singbox_tags()
|
||||
local file = get_app_path("sing-box")
|
||||
local _, tags = get_bin_version_cache(file, com["sing-box"].cmd_version, true)
|
||||
return tags or ""
|
||||
end
|
||||
|
||||
local function is_file(path)
|
||||
|
||||
Reference in new issue
Block a user