drop support for old format backups

This commit is contained in:
Girish Ramakrishnan
2017-04-27 09:43:34 -07:00
parent 65a62f9fbf
commit bfda0d4891
3 changed files with 7 additions and 23 deletions

View File

@@ -103,8 +103,7 @@ function restore(apiConfig, backupId, destination, callback) {
callback = once(callback);
var isOldFormat = backupId.endsWith('.tar.gz');
var backupFilePath = isOldFormat ? path.join(apiConfig.prefix, backupId) : getBackupFilePath(apiConfig, backupId);
var backupFilePath = getBackupFilePath(apiConfig, backupId);
debug('[%s] restore: %s -> %s', backupId, backupFilePath, destination);
@@ -127,7 +126,7 @@ function restore(apiConfig, backupId, destination, callback) {
callback(new BackupsError(BackupsError.EXTERNAL_ERROR, error.message));
});
targz.extract(s3get, isOldFormat, destination, apiConfig.key || '', callback);
targz.extract(s3get, destination, apiConfig.key || '', callback);
});
}

View File

@@ -110,8 +110,7 @@ function restore(apiConfig, backupId, destination, callback) {
callback = once(callback);
var isOldFormat = backupId.endsWith('.tar.gz');
var backupFilePath = isOldFormat ? path.join(apiConfig.prefix, backupId) : getBackupFilePath(apiConfig, backupId);
var backupFilePath = getBackupFilePath(apiConfig, backupId);
debug('[%s] restore: %s -> %s', backupId, backupFilePath, destination);
@@ -135,7 +134,7 @@ function restore(apiConfig, backupId, destination, callback) {
callback(new BackupsError(BackupsError.EXTERNAL_ERROR, error.message));
});
targz.extract(s3get, isOldFormat, destination, apiConfig.key || '', callback);
targz.extract(s3get, destination, apiConfig.key || '', callback);
});
}

View File

@@ -11,7 +11,6 @@ var assert = require('assert'),
debug = require('debug')('box:storage/targz'),
mkdirp = require('mkdirp'),
progress = require('progress-stream'),
spawn = require('child_process').spawn,
tar = require('tar-fs'),
zlib = require('zlib');
@@ -56,8 +55,7 @@ function create(sourceDirectories, key, outStream, callback) {
pack.pipe(gzip).pipe(encrypt).pipe(progressStream).pipe(outStream);
}
function extract(inStream, isOldFormat, destination, key, callback) {
assert.strictEqual(typeof isOldFormat, 'boolean');
function extract(inStream, destination, key, callback) {
assert.strictEqual(typeof destination, 'string');
assert.strictEqual(typeof key, 'string');
assert.strictEqual(typeof callback, 'function');
@@ -65,14 +63,7 @@ function extract(inStream, isOldFormat, destination, key, callback) {
mkdirp(destination, function (error) {
if (error) return callback(new BackupsError(BackupsError.EXTERNAL_ERROR, error.message));
var decrypt;
if (isOldFormat) {
let args = ['aes-256-cbc', '-d', '-pass', 'pass:' + key];
decrypt = spawn('openssl', args, { stdio: [ 'pipe', 'pipe', process.stderr ]});
} else {
decrypt = crypto.createDecipher('aes-256-cbc', key);
}
var decrypt = crypto.createDecipher('aes-256-cbc', key);
var gunzip = zlib.createGunzip({});
var progressStream = progress({ time: 10000 }); // display a progress every 10 seconds
@@ -102,11 +93,6 @@ function extract(inStream, isOldFormat, destination, key, callback) {
callback(null);
});
if (isOldFormat) {
inStream.pipe(progressStream).pipe(decrypt.stdin);
decrypt.stdout.pipe(gunzip).pipe(extract);
} else {
inStream.pipe(progressStream).pipe(decrypt).pipe(gunzip).pipe(extract);
}
inStream.pipe(progressStream).pipe(decrypt).pipe(gunzip).pipe(extract);
});
}