apps: add archive action
This commit is contained in:
+15
@@ -22,6 +22,7 @@ exports = module.exports = {
|
||||
// user actions
|
||||
install,
|
||||
uninstall,
|
||||
archive,
|
||||
|
||||
setAccessRestriction,
|
||||
setOperators,
|
||||
@@ -2477,6 +2478,20 @@ async function uninstall(app, auditSource) {
|
||||
return { taskId };
|
||||
}
|
||||
|
||||
async function archive(app, backupId, auditSource) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
assert.strictEqual(typeof backupId, 'string');
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
|
||||
const result = await backups.getByIdentifierAndStatePaged(app.id, backups.BACKUP_STATE_NORMAL, 1, 1);
|
||||
if (result.length === 0) throw new BoxError(BoxError.BAD_STATE, 'No recent backup to archive');
|
||||
if (result[0].id !== backupId) throw new BoxError(BoxError.BAD_STATE, 'Latest backup id has changed');
|
||||
|
||||
const { taskId } = await uninstall(app, auditSource);
|
||||
await backups.update(result[0].id, { archive: true });
|
||||
return { taskId };
|
||||
}
|
||||
|
||||
async function start(app, auditSource) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
|
||||
Reference in New Issue
Block a user