apps: backup is not a state anymore

this is launched as a separate task
This commit is contained in:
Girish Ramakrishnan
2025-07-18 10:56:52 +02:00
parent 0aca6c2588
commit 0fa281083e
6 changed files with 74 additions and 81 deletions

View File

@@ -11,6 +11,7 @@ exports = module.exports = {
releaseByTaskId,
TYPE_APP_TASK_PREFIX: 'app_task_',
TYPE_APP_BACKUP_PREFIX: 'app_backup_',
TYPE_BOX_UPDATE: 'box_update', // for the actual update and after the backup. this allows the backup before update do not block
TYPE_BOX_UPDATE_TASK: 'box_update_task', // for scheduling the update task
TYPE_FULL_BACKUP_TASK: 'full_backup_task', // for scheduling the backup task
@@ -50,7 +51,8 @@ function canAcquire(data, type) {
assert.strictEqual(typeof type, 'string');
if (type === exports.TYPE_BOX_UPDATE) {
if (Object.keys(data).some(k => k.startsWith(exports.TYPE_APP_TASK_PREFIX))) return new BoxError(BoxError.BAD_STATE, 'One or more apptasks are active');
if (Object.keys(data).some(k => k.startsWith(exports.TYPE_APP_TASK_PREFIX))) return new BoxError(BoxError.BAD_STATE, 'One or more app tasks are active');
if (Object.keys(data).some(k => k.startsWith(exports.TYPE_APP_BACKUP_PREFIX))) return new BoxError(BoxError.BAD_STATE, 'One or more app backups are active');
} else if (type.startsWith(exports.TYPE_APP_TASK_PREFIX)) {
if (exports.TYPE_BOX_UPDATE in data) return new BoxError(BoxError.BAD_STATE, 'Update is active');
} else if (type === exports.TYPE_FULL_BACKUP_TASK) {
@@ -59,6 +61,8 @@ function canAcquire(data, type) {
if (exports.TYPE_FULL_BACKUP_TASK in data) return new BoxError(BoxError.BAD_STATE, 'Backup task is active');
}
// TYPE_MAIL_SERVER_RESTART can co-run with everything
return null;
}