split up backupformat logic into separate files
This commit is contained in:
@@ -2,13 +2,8 @@
|
||||
|
||||
exports = module.exports = {
|
||||
api,
|
||||
|
||||
getBackupFilePath,
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
path = require('path');
|
||||
|
||||
// choose which storage backend we use for test purpose we use s3
|
||||
function api(provider) {
|
||||
switch (provider) {
|
||||
@@ -36,19 +31,3 @@ function api(provider) {
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
// This is not part of the storage api, since we don't want to pull the "format" logistics into that
|
||||
function getBackupFilePath(backupConfig, remotePath, format) {
|
||||
assert.strictEqual(typeof backupConfig, 'object');
|
||||
assert.strictEqual(typeof remotePath, 'string');
|
||||
assert.strictEqual(typeof format, 'string');
|
||||
|
||||
const rootPath = api(backupConfig.provider).getRootPath(backupConfig);
|
||||
|
||||
if (format === 'tgz') {
|
||||
const fileType = backupConfig.encryption ? '.tar.gz.enc' : '.tar.gz';
|
||||
return path.join(rootPath, remotePath + fileType);
|
||||
} else {
|
||||
return path.join(rootPath, remotePath);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user