backups: add remotePath

the main motivation is that id can be used in REST API routes. previously,
the id was a path and this had a "/" in it. This made /api/v1/backups/:backupId
not work.
This commit is contained in:
Girish Ramakrishnan
2022-04-04 14:13:27 -07:00
parent 54934c41a7
commit 452a4d9a75
15 changed files with 234 additions and 157 deletions

View File

@@ -38,17 +38,17 @@ function api(provider) {
}
// This is not part of the storage api, since we don't want to pull the "format" logistics into that
function getBackupFilePath(backupConfig, backupId, format) {
function getBackupFilePath(backupConfig, remotePath, format) {
assert.strictEqual(typeof backupConfig, 'object');
assert.strictEqual(typeof backupId, 'string');
assert.strictEqual(typeof remotePath, 'string');
assert.strictEqual(typeof format, 'string');
const basePath = api(backupConfig.provider).getBasePath(backupConfig);
const rootPath = api(backupConfig.provider).getRootPath(backupConfig);
if (format === 'tgz') {
const fileType = backupConfig.encryption ? '.tar.gz.enc' : '.tar.gz';
return path.join(basePath, backupId+fileType);
return path.join(rootPath, remotePath + fileType);
} else {
return path.join(basePath, backupId);
return path.join(rootPath, remotePath);
}
}