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

@@ -371,21 +371,6 @@ async function installCommand(app, args, progressCallback) {
await updateApp(app, { installationState: apps.ISTATE_INSTALLED, error: null, health: null });
}
async function backupCommand(app, args, progressCallback) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof args, 'object');
assert.strictEqual(typeof progressCallback, 'function');
await progressCallback({ percent: 10, message: 'Backing up' });
const backupId = await backuptask.backupApp(app, { snapshotOnly: !!args.snapshotOnly }, (progress) => {
progressCallback({ percent: 30, message: progress.message });
});
await progressCallback({ percent: 100, message: 'Done' });
await updateApp(app, { installationState: apps.ISTATE_INSTALLED, error: null });
return backupId;
}
// this command can also be called when the app is stopped. do not touch services
async function recreateCommand(app, args, progressCallback) {
assert.strictEqual(typeof app, 'object');
@@ -796,9 +781,6 @@ async function run(appId, args, progressCallback) {
case apps.ISTATE_PENDING_UPDATE:
cmd = updateCommand(app, args, progressCallback);
break;
case apps.ISTATE_PENDING_BACKUP:
cmd = backupCommand(app, args, progressCallback);
break;
case apps.ISTATE_PENDING_START:
cmd = startCommand(app, args, progressCallback);
break;
@@ -820,10 +802,7 @@ async function run(appId, args, progressCallback) {
if (error) {
debug(`run: app error for state ${app.installationState}: %o`, error);
if (app.installationState === apps.ISTATE_PENDING_BACKUP) {
// return to installed state intentionally. the error is stashed only in the task and not the app (the UI shows error state otherwise)
await safe(updateApp(app, { installationState: apps.ISTATE_INSTALLED, error: null }), { debug });
} else if (app.installationState === apps.ISTATE_PENDING_UPDATE && error.backupError) {
if (app.installationState === apps.ISTATE_PENDING_UPDATE && error.backupError) {
debug('run: update aborted because backup failed');
await safe(updateApp(app, { installationState: apps.ISTATE_INSTALLED, error: null, health: null }, { debug }));
} else {