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