merge updatechecker into updater

This commit is contained in:
Girish Ramakrishnan
2025-06-26 13:41:09 +02:00
parent a085e9ed54
commit abd640d36b
8 changed files with 292 additions and 314 deletions
+6 -5
View File
@@ -15,8 +15,7 @@ const assert = require('assert'),
HttpError = require('connect-lastmile').HttpError,
HttpSuccess = require('connect-lastmile').HttpSuccess,
safe = require('safetydance'),
updater = require('../updater.js'),
updateChecker = require('../updatechecker.js');
updater = require('../updater.js');
async function getAutoupdatePattern(req, res, next) {
const [error, pattern] = await safe(updater.getAutoupdatePattern());
@@ -49,13 +48,15 @@ async function update(req, res, next) {
}
function getUpdateInfo(req, res, next) {
next(new HttpSuccess(200, { update: updateChecker.getUpdateInfo() }));
next(new HttpSuccess(200, { update: updater.getUpdateInfoSync() }));
}
async function checkForUpdates(req, res, next) {
// it can take a while sometimes to get all the app updates one by one
req.clearTimeout();
await updateChecker.checkForUpdates({ stableOnly: false });
next(new HttpSuccess(200, { update: updateChecker.getUpdateInfo() }));
const [error, result ] = await safe(updater.checkForUpdates({ stableOnly: false }));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, { update: result }));
}