diff --git a/gate.lua b/gate.lua index fd1b5a6..90d84d2 100644 --- a/gate.lua +++ b/gate.lua @@ -113,6 +113,20 @@ local function isGateIdleForUpdate() return nowMs() >= gateBusyUntilTs end +local function getLastUpdateVersion() + if not fs.exists(".last_update_version") then return nil end + local f = fs.open(".last_update_version", "r") + if not f then return nil end + local v = f.readAll() + f.close() + return v +end + +local function setLastUpdateVersion(v) + local f = fs.open(".last_update_version", "w") + if f then f.write(tostring(v)); f.close() end +end + local function runSilentGateUpdate() local baseEnv = (getfenv and getfenv()) or _ENV or _G local env = setmetatable({ AUTO_UPDATE_SILENT = true }, { __index = baseEnv }) @@ -1430,8 +1444,8 @@ while true do pcall(function() refreshRemoteLuaVersion(guessBaseFromStatusURL(serverURL)) end) - if remoteForceUpdate and versionMismatch == true then - if expectedGateVersion ~= failedUpdateVersion then + if remoteForceUpdate then + if expectedGateVersion and expectedGateVersion ~= getLastUpdateVersion() and expectedGateVersion ~= failedUpdateVersion then pendingGateUpdate = true end end @@ -1442,6 +1456,7 @@ while true do os.sleep(0.5) local ok, updated = pcall(runSilentGateUpdate) if ok and updated then + if expectedGateVersion then setLastUpdateVersion(expectedGateVersion) end os.reboot() return end diff --git a/install_ticketmachine.lua b/install_ticketmachine.lua index c3478d1..513e30a 100644 --- a/install_ticketmachine.lua +++ b/install_ticketmachine.lua @@ -1,3 +1,11 @@ +--[[ +Author: HenryDu8133 813367384@qq.com +Date: 2026-06-28 12:58:42 +LastEditors: HenryDu8133 813367384@qq.com +LastEditTime: 2026-07-11 00:02:33 +FilePath: \TicketMachine\install_ticketmachine.lua +Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE +--]] local URL_MACHINE_HTTP = "http://gitea.fse-media.group/Henry_Du/FSE-Ticket.sys/raw/branch/main/ticketmachine.lua" local URL_UPDATE_MACHINE = "http://gitea.fse-media.group/Henry_Du/FSE-Ticket.sys/raw/branch/main/update_machine.lua" diff --git a/ticketmachine.lua b/ticketmachine.lua index 5e0033a..b9d8759 100644 --- a/ticketmachine.lua +++ b/ticketmachine.lua @@ -658,6 +658,20 @@ local function clickSound() end -- ########################### -- Background Tasks -- ########################### +local function getLastUpdateVersion() + if not fs.exists(".last_update_version") then return nil end + local f = fs.open(".last_update_version", "r") + if not f then return nil end + local v = f.readAll() + f.close() + return v +end + +local function setLastUpdateVersion(v) + local f = fs.open(".last_update_version", "w") + if f then f.write(tostring(v)); f.close() end +end + local function runSilentMachineUpdate() local baseEnv = (getfenv and getfenv()) or _ENV or _G local env = setmetatable({ AUTO_UPDATE_SILENT = true }, { __index = baseEnv }) @@ -667,8 +681,9 @@ end local function backgroundSyncTask() pcall(refreshConfigOnce) while true do - if type(CFG) == 'table' and type(CFG.force_update) == 'boolean' and CFG.force_update == true and versionMismatch == true then - if expectedMachineVersion ~= failedUpdateVersion then + 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 @@ -679,12 +694,14 @@ local function backgroundSyncTask() sleep(0.5) local ok, updated = pcall(runSilentMachineUpdate) if ok and updated then + local expected = CFG.lua_versions and CFG.lua_versions.ticketmachine + if expected then setLastUpdateVersion(expected) end os.reboot() return end isUpdating = false pendingMachineUpdate = false - failedUpdateVersion = expectedMachineVersion + failedUpdateVersion = CFG.lua_versions and CFG.lua_versions.ticketmachine pcall(drawVersionIndicator) end sleep(UPDATE_CHECK_INTERVAL)