split up backupformat logic into separate files

This commit is contained in:
Girish Ramakrishnan
2022-04-28 18:43:14 -07:00
parent c67d9fd082
commit 7123ec433c
9 changed files with 539 additions and 436 deletions
-21
View File
@@ -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);
}
}