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:
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
getBasePath,
|
||||
getRootPath,
|
||||
checkPreconditions,
|
||||
|
||||
upload,
|
||||
@@ -46,7 +46,7 @@ const assert = require('assert'),
|
||||
shell = require('../shell.js');
|
||||
|
||||
// storage api
|
||||
function getBasePath(apiConfig) {
|
||||
function getRootPath(apiConfig) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
|
||||
switch (apiConfig.provider) {
|
||||
@@ -78,7 +78,7 @@ async function checkPreconditions(apiConfig, dataLayout, callback) {
|
||||
|
||||
debug(`checkPreconditions: ${used} bytes`);
|
||||
|
||||
const [error, result] = await safe(df.file(getBasePath(apiConfig)));
|
||||
const [error, result] = await safe(df.file(getRootPath(apiConfig)));
|
||||
if (error) return callback(new BoxError(BoxError.FS_ERROR, `Error when checking for disk space: ${error.message}`));
|
||||
|
||||
// Check filesystem is mounted so we don't write into the actual folder on disk
|
||||
@@ -318,7 +318,7 @@ function testConfig(apiConfig, callback) {
|
||||
if (!safe.child_process.execSync(`mountpoint -q -- ${apiConfig.mountPoint}`)) return callback(new BoxError(BoxError.BAD_FIELD, `${apiConfig.mountPoint} is not mounted`));
|
||||
}
|
||||
|
||||
const basePath = getBasePath(apiConfig);
|
||||
const basePath = getRootPath(apiConfig);
|
||||
const field = apiConfig.provider === PROVIDER_FILESYSTEM ? 'backupFolder' : 'mountPoint';
|
||||
|
||||
if (!safe.fs.mkdirSync(path.join(basePath, 'snapshot'), { recursive: true }) && safe.error.code !== 'EEXIST') {
|
||||
|
||||
Reference in New Issue
Block a user