feat: decouple OTA updates into dedicated fast endpoints to avoid db timeouts

This commit is contained in:
2026-07-11 12:22:48 +08:00
parent bd6ef05722
commit 79ae234232
4 changed files with 26 additions and 12 deletions
+13 -3
View File
@@ -151,6 +151,18 @@ const resolveCurrentStationCode = (body, resolveStation) => {
return codes[0] || direct || fallback || '';
};
// Dedicated lightweight OTA update endpoints
let globalUpdateCounter = Date.now();
router.post('/trigger-update', (req, res) => {
globalUpdateCounter++;
res.json({ ok: true, update_counter: globalUpdateCounter });
});
router.get('/check-update', (req, res) => {
res.json({ update_counter: globalUpdateCounter });
});
// Config
router.get('/config', (req, res) => {
const cfg = DataService.getConfig();
@@ -190,9 +202,7 @@ router.put('/config', async (req, res) => {
if (typeof incoming.force_update === 'boolean') {
cfg.force_update = incoming.force_update;
}
if (incoming.update_counter) {
cfg.update_counter = incoming.update_counter;
}
// remove unused update_counter
await DataService.saveConfig(cfg);
appendReqLog(req, { category: 'admin', type: 'update_config_generic', detail: incoming });
io.emit('config:updated', cfg);