mail: fix rebuild
also fixes dangerous code that downloads mail backup if infra version is 'none'
This commit is contained in:
@@ -10,6 +10,7 @@ exports = module.exports = {
|
||||
isRebootRequired,
|
||||
|
||||
onActivated,
|
||||
onRestored,
|
||||
|
||||
setupDnsAndCert,
|
||||
|
||||
@@ -27,6 +28,7 @@ const apps = require('./apps.js'),
|
||||
assert = require('assert'),
|
||||
AuditSource = require('./auditsource.js'),
|
||||
backups = require('./backups.js'),
|
||||
backuptask = require('./backuptask.js'),
|
||||
BoxError = require('./boxerror.js'),
|
||||
branding = require('./branding.js'),
|
||||
constants = require('./constants.js'),
|
||||
@@ -83,6 +85,24 @@ async function onActivated(options) {
|
||||
await reverseProxy.writeDefaultConfig({ activated :true });
|
||||
}
|
||||
|
||||
async function onRestored(options) {
|
||||
assert.strictEqual(typeof options, 'object');
|
||||
|
||||
debug('onRestored: downloading mail');
|
||||
|
||||
const [error, results] = await safe(backups.getByIdentifierAndStatePaged(backups.BACKUP_IDENTIFIER_MAIL, backups.BACKUP_STATE_NORMAL, 1, 1));
|
||||
if (error || results.length == 0) {
|
||||
debug('startMail: could not find backup to restore', error, results);
|
||||
} else {
|
||||
debug(`startMail: downloading backup ${results[0].id}`);
|
||||
const restoreConfig = { backupId: results[0].id, backupFormat: results[0].format };
|
||||
// have to wait for download before starting mail container because we download as non-root user
|
||||
await backuptask.downloadMail(restoreConfig, (progress) => debug(`startMail: ${progress.message}`));
|
||||
}
|
||||
|
||||
await onActivated(options);
|
||||
}
|
||||
|
||||
async function notifyUpdate() {
|
||||
const version = safe.fs.readFileSync(paths.VERSION_FILE, 'utf8');
|
||||
if (version === constants.VERSION) return;
|
||||
|
||||
Reference in New Issue
Block a user