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:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user