refactor: rename updater functions to have box in them

This commit is contained in:
Girish Ramakrishnan
2025-06-20 19:04:55 +02:00
parent d7fdfd6d71
commit 2db99e7807
6 changed files with 13 additions and 13 deletions
+8 -8
View File
@@ -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;