mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-05 18:44:03 +08:00
💐 Sync 2026-07-18 20:20:11
This commit is contained in:
1 parent
7d78922185
commit
147206645f
66 files changed
+14022
-10358
No files matched your search
@@ -603,7 +603,19 @@ end
|
||||
--- Returns the installed version of luci-app-openclash.
|
||||
-- Supports both opkg and apk package managers.
|
||||
-- @return String containing the version number, or "0" if not found
|
||||
-- NOTE: The module-level cache (_oc_version_cache) provides per-request
|
||||
-- deduplication. In OpenWrt LuCI CGI mode each HTTP request spawns a new Lua
|
||||
-- process, so cross-request caching is impossible.
|
||||
-- Since require() returns the same module instance (package.loaded), the
|
||||
-- first call caches the result and subsequent calls avoid redundant shell
|
||||
-- commands. No time-based expiration is needed — the version is immutable
|
||||
-- for the lifetime of a request.
|
||||
local _oc_version_cache = nil
|
||||
|
||||
function oc_version()
|
||||
if _oc_version_cache ~= nil then
|
||||
return _oc_version_cache
|
||||
end
|
||||
local v
|
||||
if pkg_type() == "opkg" then
|
||||
v = SYS.exec("rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep '^Version:' |awk '{print $2}' |tr -d '\n'")
|
||||
@@ -613,6 +625,7 @@ function oc_version()
|
||||
if v == "" then
|
||||
v = "0"
|
||||
end
|
||||
_oc_version_cache = v
|
||||
return v
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user