aa8c23c8b3
notes: * backup root cannot come from backend. for dynamic mounts backend cannot know where it is mounted * backupConfig is 3 parts - format / mount / password . there is also this rootPath (which should not be in db) * password should be stored separately in settings at some point * format has to be passed along everywhere because we allow restore from same backupConfig but different format. we do this by saving the format in the backups table fixes #819
112 lines
2.9 KiB
JavaScript
112 lines
2.9 KiB
JavaScript
'use strict';
|
|
|
|
exports = module.exports = {
|
|
getProviderStatus,
|
|
getAvailableSize,
|
|
|
|
upload,
|
|
exists,
|
|
download,
|
|
copy,
|
|
|
|
listDir,
|
|
|
|
remove,
|
|
removeDir,
|
|
|
|
testConfig,
|
|
removePrivateFields,
|
|
injectPrivateFields
|
|
};
|
|
|
|
const assert = require('assert'),
|
|
BoxError = require('../boxerror.js'),
|
|
debug = require('debug')('box:storage/noop');
|
|
|
|
async function getProviderStatus(apiConfig) {
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
|
|
return { state: 'active' };
|
|
}
|
|
|
|
async function getAvailableSize(apiConfig) {
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
|
|
return Number.POSITIVE_INFINITY;
|
|
}
|
|
|
|
function upload(apiConfig, backupFilePath, sourceStream, callback) {
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
assert.strictEqual(typeof backupFilePath, 'string');
|
|
assert.strictEqual(typeof sourceStream, 'object');
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
debug('upload: %s', backupFilePath);
|
|
|
|
callback(null);
|
|
}
|
|
|
|
async function exists(apiConfig, backupFilePath) {
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
assert.strictEqual(typeof backupFilePath, 'string');
|
|
|
|
debug(`exists: ${backupFilePath}`);
|
|
|
|
return false;
|
|
}
|
|
|
|
async function download(apiConfig, backupFilePath) {
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
assert.strictEqual(typeof backupFilePath, 'string');
|
|
|
|
debug('download: %s', backupFilePath);
|
|
|
|
throw new BoxError(BoxError.NOT_IMPLEMENTED, 'Cannot download from noop backend');
|
|
}
|
|
|
|
function listDir(apiConfig, dir, batchSize, iteratorCallback, callback) {
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
assert.strictEqual(typeof dir, 'string');
|
|
assert.strictEqual(typeof batchSize, 'number');
|
|
assert.strictEqual(typeof iteratorCallback, 'function');
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
callback();
|
|
}
|
|
|
|
async function copy(apiConfig, oldFilePath, newFilePath, progressCallback) {
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
assert.strictEqual(typeof oldFilePath, 'string');
|
|
assert.strictEqual(typeof newFilePath, 'string');
|
|
assert.strictEqual(typeof progressCallback, 'function');
|
|
|
|
debug(`copy: ${oldFilePath} -> ${newFilePath}`);
|
|
}
|
|
|
|
async function remove(apiConfig, filename) {
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
assert.strictEqual(typeof filename, 'string');
|
|
|
|
debug(`remove: ${filename}`);
|
|
}
|
|
|
|
async function removeDir(apiConfig, pathPrefix, progressCallback) {
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
assert.strictEqual(typeof pathPrefix, 'string');
|
|
assert.strictEqual(typeof progressCallback, 'function');
|
|
|
|
debug(`removeDir: ${pathPrefix}`);
|
|
}
|
|
|
|
async function testConfig(apiConfig) {
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
}
|
|
|
|
function removePrivateFields(apiConfig) {
|
|
return apiConfig;
|
|
}
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
function injectPrivateFields(newConfig, currentConfig) {
|
|
}
|