Use key to determine if we should encrypt or not

When encrypting we use the .enc extension. When not encrypting, we
use the plain .tar.gz extension.

Fixes #315
This commit is contained in:
Girish Ramakrishnan
2017-04-27 09:47:31 -07:00
parent 893f9d87bc
commit 9635f9aa24
3 changed files with 30 additions and 23 deletions

View File

@@ -24,8 +24,6 @@ var assert = require('assert'),
path = require('path'),
targz = require('./targz.js');
var FILE_TYPE = '.tar.gz.enc';
// test only
var originalAWS;
function mockInject(mock) {
@@ -61,6 +59,8 @@ function getBackupFilePath(apiConfig, backupId) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof backupId, 'string');
const FILE_TYPE = apiConfig.key ? '.tar.gz.enc' : '.tar.gz';
return path.join(apiConfig.prefix, backupId.endsWith(FILE_TYPE) ? backupId : backupId+FILE_TYPE);
}
@@ -99,7 +99,7 @@ function backup(apiConfig, backupId, sourceDirectories, callback) {
callback(null);
});
targz.create(sourceDirectories, apiConfig.key || '', passThrough, callback);
targz.create(sourceDirectories, apiConfig.key || null, passThrough, callback);
});
}
@@ -135,7 +135,7 @@ function restore(apiConfig, backupId, destination, callback) {
callback(new BackupsError(BackupsError.EXTERNAL_ERROR, error.message));
});
targz.extract(s3get, destination, apiConfig.key || '', callback);
targz.extract(s3get, destination, apiConfig.key || null, callback);
});
}