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
+4 -3
View File
@@ -81,7 +81,7 @@ const apps = require('../apps.js'),
HttpSuccess = require('connect-lastmile').HttpSuccess,
metrics = require('../metrics.js'),
safe = require('safetydance'),
updateChecker = require('../updatechecker.js'),
updater = require('../updater.js'),
users = require('../users.js'),
WebSocket = require('ws');
@@ -1049,8 +1049,9 @@ 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 }); // appId argument is ignored for the moment
next(new HttpSuccess(200, { update: updateChecker.getUpdateInfo() }));
const [error, result] = await safe(updater.checkForUpdates({ stableOnly: false })); // appId argument is ignored for the moment
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, { update: result[req.resource.app.id] }));
}
async function getTask(req, res, next) {
+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 }));
}