apps: add backup start and finish events
these can then be used by the UI to show errors fixes #797
This commit is contained in:
+12
-8
@@ -1034,22 +1034,24 @@ async function onTaskFinished(appId, installationState, taskId, error) {
|
||||
const success = !error;
|
||||
const errorMessage = error?.message || null;
|
||||
|
||||
const app = await get(appId);
|
||||
const task = await tasks.get(taskId);
|
||||
if (!app || !task) return;
|
||||
|
||||
switch (installationState) {
|
||||
case exports.ISTATE_PENDING_DATA_DIR_MIGRATION:
|
||||
if (success) await safe(services.rebuildService('sftp', AuditSource.APPTASK), { debug });
|
||||
break;
|
||||
case exports.ISTATE_PENDING_UPDATE: {
|
||||
const app = await get(appId);
|
||||
if (!app) break;
|
||||
const task = await tasks.get(taskId);
|
||||
if (!task) break;
|
||||
|
||||
const fromManifest = success ? task.args[1].updateConfig.manifest : app.manifest;
|
||||
const toManifest = success ? app.manifest : task.args[1].updateConfig.manifest;
|
||||
|
||||
await eventlog.add(eventlog.ACTION_APP_UPDATE_FINISH, AuditSource.APPTASK, { app, toManifest, fromManifest, success, errorMessage });
|
||||
break;
|
||||
}
|
||||
case exports.ISTATE_PENDING_BACKUP:
|
||||
await eventlog.add(eventlog.ACTION_APP_BACKUP_FINISH, AuditSource.APPTASK, { app, success, errorMessage, backupId: task.result });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2067,7 +2069,7 @@ async function clone(app, data, user, auditSource) {
|
||||
|
||||
await purchaseApp({ appId: newAppId, appstoreId: app.appStoreId, manifestId: manifest.id || 'customapp' });
|
||||
|
||||
const restoreConfig = { backupId: backupId, backupFormat: backupInfo.format };
|
||||
const restoreConfig = { backupId, backupFormat: backupInfo.format };
|
||||
const task = {
|
||||
args: { restoreConfig, overwriteDns, skipDnsSetup, oldManifest: null },
|
||||
values: {},
|
||||
@@ -2080,7 +2082,7 @@ async function clone(app, data, user, auditSource) {
|
||||
newApp.alternateDomains.forEach(function (ad) { ad.fqdn = dns.fqdn(ad.subdomain, domainObjectMap[ad.domain]); });
|
||||
newApp.aliasDomains.forEach(function (ad) { ad.fqdn = dns.fqdn(ad.subdomain, domainObjectMap[ad.domain]); });
|
||||
|
||||
await eventlog.add(eventlog.ACTION_APP_CLONE, auditSource, { appId: newAppId, oldAppId: appId, backupId: backupId, oldApp: app, newApp: newApp, taskId });
|
||||
await eventlog.add(eventlog.ACTION_APP_CLONE, auditSource, { appId: newAppId, oldAppId: appId, backupId, oldApp: app, newApp, taskId });
|
||||
|
||||
return { id: newAppId, taskId };
|
||||
}
|
||||
@@ -2276,8 +2278,9 @@ async function autoupdateApps(updateInfo, auditSource) { // updateInfo is { appI
|
||||
}
|
||||
}
|
||||
|
||||
async function backup(app) {
|
||||
async function backup(app, auditSource) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
|
||||
const appId = app.id;
|
||||
|
||||
@@ -2289,6 +2292,7 @@ async function backup(app) {
|
||||
values: {}
|
||||
};
|
||||
const taskId = await addTask(appId, exports.ISTATE_PENDING_BACKUP, task);
|
||||
await eventlog.add(eventlog.ACTION_APP_BACKUP, auditSource, { app, appId, taskId });
|
||||
|
||||
return { taskId };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user