Fix ticket machine update logic
This commit is contained in:
+15
-18
@@ -719,30 +719,27 @@ end
|
|||||||
local function backgroundSyncTask()
|
local function backgroundSyncTask()
|
||||||
pcall(refreshConfigOnce)
|
pcall(refreshConfigOnce)
|
||||||
while true do
|
while true do
|
||||||
if type(CFG) == 'table' and type(CFG.force_update) == 'boolean' and CFG.force_update == true then
|
if type(CFG) == 'table' and type(CFG.force_update) == 'boolean' and CFG.force_update == true and versionMismatch == true then
|
||||||
local expected = CFG.lua_versions and CFG.lua_versions.ticketmachine
|
|
||||||
if expected and expected ~= getLastUpdateVersion() and expected ~= failedUpdateVersion then
|
|
||||||
pendingMachineUpdate = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if pendingMachineUpdate then
|
|
||||||
isUpdating = true
|
isUpdating = true
|
||||||
lastUpdateError = nil
|
|
||||||
pcall(drawVersionIndicator)
|
pcall(drawVersionIndicator)
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
local ok, updated = pcall(runSilentMachineUpdate)
|
|
||||||
if ok and updated == true then
|
-- Extreme fallback: just run the update script directly
|
||||||
local expected = CFG.lua_versions and CFG.lua_versions.ticketmachine
|
local baseEnv = (getfenv and getfenv()) or _ENV or _G
|
||||||
if expected then setLastUpdateVersion(expected) end
|
local env = setmetatable({ AUTO_UPDATE_SILENT = true }, { __index = baseEnv })
|
||||||
os.reboot()
|
local fn = loadfile('update_machine.lua', env)
|
||||||
return
|
if fn then
|
||||||
|
local ok, err = pcall(fn, '--silent')
|
||||||
|
if not ok then
|
||||||
|
lastUpdateError = string.sub(tostring(err), 1, 30)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
lastUpdateError = "loadfile failed"
|
||||||
end
|
end
|
||||||
|
|
||||||
isUpdating = false
|
isUpdating = false
|
||||||
pendingMachineUpdate = false
|
|
||||||
lastUpdateError = tostring(updated)
|
|
||||||
failedUpdateVersion = CFG.lua_versions and CFG.lua_versions.ticketmachine
|
|
||||||
pcall(drawVersionIndicator)
|
pcall(drawVersionIndicator)
|
||||||
|
sleep(10) -- Sleep 10s to prevent spamming
|
||||||
end
|
end
|
||||||
sleep(UPDATE_CHECK_INTERVAL)
|
sleep(UPDATE_CHECK_INTERVAL)
|
||||||
pcall(refreshConfigOnce)
|
pcall(refreshConfigOnce)
|
||||||
|
|||||||
Reference in New Issue
Block a user