revert: remove _update_ts injection as it breaks ticket scanning
This commit is contained in:
+1
-48
@@ -84,14 +84,10 @@ local function fetchHTTP(url)
|
||||
end
|
||||
end
|
||||
|
||||
local checkGlobalUpdate = nil
|
||||
|
||||
local function fetchJSON(url)
|
||||
local txt = fetchHTTP(url)
|
||||
if not txt then return nil end
|
||||
local parsed = jsonDecode(txt)
|
||||
if checkGlobalUpdate then checkGlobalUpdate(parsed) end
|
||||
return parsed
|
||||
return jsonDecode(txt)
|
||||
end
|
||||
|
||||
local function ensureDir(path)
|
||||
@@ -158,7 +154,6 @@ local function postJSON(url, dataTable)
|
||||
return false, code, nil, tostring(err or 'request error')
|
||||
end
|
||||
local parsed = jsonDecode(body)
|
||||
if checkGlobalUpdate then checkGlobalUpdate(parsed) end
|
||||
if code < 200 or code >= 300 then
|
||||
local msg = nil
|
||||
if type(parsed) == 'table' then
|
||||
@@ -694,48 +689,6 @@ local function drawVersionIndicator()
|
||||
termDev.setTextColor(colors.white)
|
||||
end
|
||||
|
||||
checkGlobalUpdate = function(parsed)
|
||||
if type(parsed) == 'table' and parsed._update_ts then
|
||||
local remoteTs = tonumber(parsed._update_ts)
|
||||
if remoteTs and remoteTs > 0 then
|
||||
local attemptFile = ".last_update_ts"
|
||||
local tried = 0
|
||||
if fs.exists(attemptFile) then
|
||||
local f = fs.open(attemptFile, "r")
|
||||
tried = tonumber(f and f.readAll() or "0") or 0
|
||||
if f then f.close() end
|
||||
end
|
||||
if remoteTs > tried then
|
||||
isUpdating = true
|
||||
pcall(drawVersionIndicator)
|
||||
sleep(0.5)
|
||||
|
||||
local f = fs.open(attemptFile, "w")
|
||||
if f then f.write(tostring(remoteTs)); f.close() end
|
||||
|
||||
local env = setmetatable({ AUTO_UPDATE_SILENT = true }, { __index = _G or getfenv() or _ENV })
|
||||
local fn, err = loadfile("update_machine.lua", env)
|
||||
if fn then
|
||||
local ok, res = pcall(fn, "--silent")
|
||||
if not ok then
|
||||
lastUpdateError = string.sub(tostring(res), 1, 30)
|
||||
end
|
||||
else
|
||||
lastUpdateError = "loadfile failed: " .. tostring(err)
|
||||
end
|
||||
|
||||
isUpdating = false
|
||||
pcall(drawVersionIndicator)
|
||||
|
||||
if lastUpdateError then
|
||||
sleep(3)
|
||||
end
|
||||
os.reboot()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function checkAndApplyUpdate()
|
||||
if type(CFG) ~= 'table' then return end
|
||||
local remoteTs = tonumber(CFG.update_timestamp)
|
||||
|
||||
Reference in New Issue
Block a user