feat: use simpler update_counter instead of timestamp for OTA updates

This commit is contained in:
2026-07-11 12:00:20 +08:00
parent 61e98cd6d5
commit 1f60c74ec2
5 changed files with 8 additions and 9 deletions
+1 -1
View File
@@ -101,7 +101,7 @@ end
local function checkAndApplyUpdate() local function checkAndApplyUpdate()
if type(CFG) ~= 'table' then return end if type(CFG) ~= 'table' then return end
local remoteTs = tonumber(CFG.update_timestamp) local remoteTs = tonumber(CFG.update_counter)
if not remoteTs or remoteTs <= 0 then return end if not remoteTs or remoteTs <= 0 then return end
+3 -3
View File
@@ -164,7 +164,7 @@ router.get('/config', (req, res) => {
promotion: cfg.promotion || { name: '', discount: 1 }, promotion: cfg.promotion || { name: '', discount: 1 },
lua_versions: cfg.lua_versions || {}, lua_versions: cfg.lua_versions || {},
force_update: cfg.force_update === true, force_update: cfg.force_update === true,
update_timestamp: cfg.update_timestamp || 0 update_counter: cfg.update_counter || 0
}); });
}); });
@@ -190,8 +190,8 @@ router.put('/config', async (req, res) => {
if (typeof incoming.force_update === 'boolean') { if (typeof incoming.force_update === 'boolean') {
cfg.force_update = incoming.force_update; cfg.force_update = incoming.force_update;
} }
if (incoming.update_timestamp) { if (incoming.update_counter) {
cfg.update_timestamp = incoming.update_timestamp; cfg.update_counter = incoming.update_counter;
} }
await DataService.saveConfig(cfg); await DataService.saveConfig(cfg);
appendReqLog(req, { category: 'admin', type: 'update_config_generic', detail: incoming }); appendReqLog(req, { category: 'admin', type: 'update_config_generic', detail: incoming });
+1 -1
View File
@@ -230,7 +230,7 @@ router.get('/config', (req, res) => {
promotion: { name: cfg.promotion?.name || '', discount: cfg.promotion?.discount ?? 1 }, promotion: { name: cfg.promotion?.name || '', discount: cfg.promotion?.discount ?? 1 },
lua_versions: cfg.lua_versions || {}, lua_versions: cfg.lua_versions || {},
force_update: cfg.force_update === true, force_update: cfg.force_update === true,
update_timestamp: cfg.update_timestamp || 0 update_counter: cfg.update_counter || 0
}); });
}); });
+1 -2
View File
@@ -691,7 +691,7 @@ end
local function checkAndApplyUpdate() local function checkAndApplyUpdate()
if type(CFG) ~= 'table' then return end if type(CFG) ~= 'table' then return end
local remoteTs = tonumber(CFG.update_timestamp) local remoteTs = tonumber(CFG.update_counter)
if not remoteTs or remoteTs <= 0 then return end if not remoteTs or remoteTs <= 0 then return end
@@ -728,7 +728,6 @@ local function checkAndApplyUpdate()
if lastUpdateError then if lastUpdateError then
sleep(3) sleep(3)
end end
os.reboot() os.reboot()
end end
+2 -2
View File
@@ -1483,8 +1483,8 @@ createApp({
isPushingUpdate.value = true; isPushingUpdate.value = true;
// 放弃版本号验证,直接使用时间戳强制下发更新指令 // 每次点击,更新计数器 +1,终端只要看到计数器变大就会更新
config.update_timestamp = Date.now(); config.update_counter = (config.update_counter || 0) + 1;
config.force_update = true; config.force_update = true;
try { try {