backups: encrypted backups must have .enc extension

This commit is contained in:
Girish Ramakrishnan
2023-07-24 22:25:06 +05:30
parent febac9e8ca
commit 3d5c21d9ca
7 changed files with 28 additions and 42 deletions

View File

@@ -176,6 +176,7 @@ const appstore = require('./appstore.js'),
os = require('os'),
path = require('path'),
paths = require('./paths.js'),
PassThrough = require('stream').PassThrough,
reverseProxy = require('./reverseproxy.js'),
safe = require('safetydance'),
semver = require('semver'),
@@ -2669,12 +2670,20 @@ async function getBackupDownloadStream(app, backupId) {
const backupConfig = await settings.getBackupConfig();
return new Promise((resolve, reject) => {
storage.api(backupConfig.provider).download(backupConfig, tgz.getBackupFilePath(backupConfig, backup.remotePath), function (error, sourceStream) {
if (error) return reject(error);
resolve(sourceStream);
});
const ps = new PassThrough();
const stream = await storage.api(backupConfig.provider).download(backupConfig, tgz.getBackupFilePath(backupConfig, backup.remotePath));
stream.on('error', function(error) {
debug(`getBackupDownloadStream: read stream error: ${error.message}`);
ps.emit('error', new BoxError(BoxError.EXTERNAL_ERROR, error));
});
stream.pipe(ps);
const now = (new Date()).toISOString().replace(/:|T/g,'-').replace(/\..*/,'');
const encryptionSuffix = backup.encryptionVersion ? '.enc' : '';
const filename = `app-backup-${now} (${app.fqdn}).tar.gz${encryptionSuffix}`;
return { stream: ps, filename };
}
async function restoreInstalledApps(options, auditSource) {