diff --git a/src/cron.js b/src/cron.js index 9adc8ed37..3bb64212d 100644 --- a/src/cron.js +++ b/src/cron.js @@ -250,7 +250,7 @@ async function handleAutoupdatePatternChanged(pattern) { // do box before app updates. for the off chance that the box logic fixes some app update logic issue if (updateInfo.box && !updateInfo.box.unstable) { debug('Starting box autoupdate to %j', updateInfo.box.version); - const [error] = await safe(updater.updateToLatest({ skipBackup: false }, AuditSource.CRON)); + const [error] = await safe(updater.startBoxUpdateTask({ skipBackup: false }, AuditSource.CRON)); if (!error) return; // do not start app updates when a box update got scheduled debug(`Failed to start box autoupdate task: ${error.message}`); // fall through to update apps if box update never started (failed ubuntu or avx check) diff --git a/src/platform.js b/src/platform.js index e6f11748b..f666e5080 100644 --- a/src/platform.js +++ b/src/platform.js @@ -181,7 +181,7 @@ async function initialize() { await safe(reverseProxy.writeDefaultConfig({ activated: false }), { debug }); // ok to fail if no disk space } - await updater.notifyUpdate(); + await updater.notifyBoxUpdate(); if (await users.isActivated()) safe(onActivated({ skipDnsSetup: false }), { debug }); // run in background } diff --git a/src/routes/updater.js b/src/routes/updater.js index 85500797d..111fb910d 100644 --- a/src/routes/updater.js +++ b/src/routes/updater.js @@ -40,7 +40,7 @@ async function update(req, res, next) { if ('skipBackup' in req.body && typeof req.body.skipBackup !== 'boolean') return next(new HttpError(400, 'skipBackup must be a boolean')); // this only initiates the update, progress can be checked via the progress route - const [error, taskId] = await safe(updater.updateToLatest(req.body, AuditSource.fromRequest(req))); + const [error, taskId] = await safe(updater.startBoxUpdateTask(req.body, AuditSource.fromRequest(req))); if (error && error.reason === BoxError.NOT_FOUND) return next(new HttpError(422, error.message)); if (error && error.reason === BoxError.BAD_STATE) return next(new HttpError(409, error.message)); if (error) return next(new HttpError(500, error)); diff --git a/src/tasks.js b/src/tasks.js index b6c9182f9..fdc743660 100644 --- a/src/tasks.js +++ b/src/tasks.js @@ -21,7 +21,7 @@ exports = module.exports = { // task types. if you add a task here, fill up the function table in taskworker and dashboard client.js TASK_APP: 'app', TASK_BACKUP: 'backup', - TASK_UPDATE: 'update', + TASK_BOX_UPDATE: 'boxUpdate', TASK_CHECK_CERTS: 'checkCerts', TASK_SYNC_DYNDNS: 'syncDyndns', TASK_PREPARE_DASHBOARD_LOCATION: 'prepareDashboardLocation', diff --git a/src/taskworker.js b/src/taskworker.js index b2fe76b2d..af37a9ca3 100755 --- a/src/taskworker.js +++ b/src/taskworker.js @@ -23,7 +23,7 @@ const apptask = require('./apptask.js'), const TASKS = { // indexed by task type app: apptask.run, backup: backuptask.fullBackup, - update: updater.update, + boxUpdate: updater.updateBox, checkCerts: reverseProxy.checkCerts, prepareDashboardLocation: dashboard.prepareLocation, cleanBackups: backupCleaner.run, diff --git a/src/updater.js b/src/updater.js index b20659031..763c4d502 100644 --- a/src/updater.js +++ b/src/updater.js @@ -4,10 +4,10 @@ exports = module.exports = { setAutoupdatePattern, getAutoupdatePattern, - updateToLatest, - update, + startBoxUpdateTask, + updateBox, - notifyUpdate + notifyBoxUpdate }; const apps = require('./apps.js'), @@ -152,7 +152,7 @@ async function checkFreeDiskSpace(neededSpace) { if (diskUsage.available < neededSpace) throw new BoxError(BoxError.FS_ERROR, `Not enough disk space. Updates require at least 2GB of free space. Available: ${df.prettyBytes(diskUsage.available)}`); } -async function update(boxUpdateInfo, options, progressCallback) { +async function updateBox(boxUpdateInfo, options, progressCallback) { assert(boxUpdateInfo && typeof boxUpdateInfo === 'object'); assert(options && typeof options === 'object'); assert.strictEqual(typeof progressCallback, 'function'); @@ -196,7 +196,7 @@ async function checkUpdateRequirements(boxUpdateInfo) { } } -async function updateToLatest(options, auditSource) { +async function startBoxUpdateTask(options, auditSource) { assert.strictEqual(typeof options, 'object'); assert.strictEqual(typeof auditSource, 'object'); @@ -213,12 +213,12 @@ async function updateToLatest(options, auditSource) { const backupConfig = await backups.getConfig(); const memoryLimit = backupConfig.limits?.memoryLimit ? Math.max(backupConfig.limits.memoryLimit/1024/1024, 400) : 400; - const taskId = await tasks.add(tasks.TASK_UPDATE, [ boxUpdateInfo, options ]); + const taskId = await tasks.add(tasks.TASK_BOX_UPDATE, [ boxUpdateInfo, options ]); await eventlog.add(eventlog.ACTION_UPDATE, auditSource, { taskId, boxUpdateInfo }); // background tasks.startTask(taskId, { timeout: 20 * 60 * 60 * 1000 /* 20 hours */, nice: 15, memoryLimit }) - .then(() => debug('updateToLatest: internal error. impossible code path')) + .then(() => debug('startBoxUpdateTask: internal error. impossible code path')) .catch(async (error) => { debug('Update failed with error. %o', error); @@ -232,7 +232,7 @@ async function updateToLatest(options, auditSource) { return taskId; } -async function notifyUpdate() { +async function notifyBoxUpdate() { const version = safe.fs.readFileSync(paths.VERSION_FILE, 'utf8'); if (version === constants.VERSION) return;