archive: implement unarchive
made a separate route instead of reusing install route. this was because we want to copy over all the old app config as much as possible.
This commit is contained in:
@@ -6,15 +6,18 @@ exports = module.exports = {
|
||||
add,
|
||||
list,
|
||||
listBackupIds,
|
||||
del
|
||||
del,
|
||||
unarchive
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
const apps = require('./apps.js'),
|
||||
assert = require('assert'),
|
||||
BoxError = require('./boxerror.js'),
|
||||
database = require('./database.js'),
|
||||
eventlog = require('./eventlog.js'),
|
||||
safe = require('safetydance'),
|
||||
uuid = require('uuid');
|
||||
uuid = require('uuid'),
|
||||
_ = require('underscore');
|
||||
|
||||
const ARCHIVE_FIELDS = [ 'id', 'backupId', 'creationTime', 'appConfigJson', '(icon IS NOT NULL) AS hasIcon', '(appStoreIcon IS NOT NULL) AS hasAppStoreIcon' ];
|
||||
|
||||
@@ -104,3 +107,32 @@ async function del(archive, auditSource) {
|
||||
|
||||
await eventlog.add(eventlog.ACTION_ARCHIVES_DEL, auditSource, { id: archive.id, backupId: archive.backupId });
|
||||
}
|
||||
|
||||
async function unarchive(archive, data, auditSource) {
|
||||
assert.strictEqual(typeof archive, 'object');
|
||||
assert.strictEqual(typeof data, 'object');
|
||||
assert(auditSource && typeof auditSource === 'object');
|
||||
|
||||
const appConfig = archive.appConfig;
|
||||
|
||||
const dolly = _.pick(appConfig, 'appStoreId', 'manifest', 'memoryLimit', 'cpuQuota', 'crontab', 'reverseProxyConfig', 'env', 'servicesConfig',
|
||||
'tags', 'label', 'enableMailbox', 'mailboxDisplayName', 'mailboxName', 'mailboxDomain', 'enableInbox', 'inboxName', 'inboxDomain', 'devices',
|
||||
'enableTurn', 'enableRedis', 'mounts', 'enableBackup', 'enableAutomaticUpdate', 'accessRestriction', 'operators', 'sso');
|
||||
|
||||
// intentionally not filled up: redirectDomain, aliasDomains, mailboxDomain
|
||||
const newAppData = Object.assign(dolly, {
|
||||
// from request
|
||||
subdomain: data.subdomain,
|
||||
domain: data.domain,
|
||||
secondaryDomains: data.secondaryDomains || {},
|
||||
ports: data.ports || null,
|
||||
overwriteDns: 'overwriteDns' in data ? data.overwriteDns : false,
|
||||
mailboxDomain: data.domain, // archive's mailboxDomain may not exist
|
||||
|
||||
// from the archive
|
||||
icon: archive.icon,
|
||||
backupId: archive.backupId,
|
||||
});
|
||||
|
||||
return await apps.install(newAppData, auditSource);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user