2017-05-19 14:50:29 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
exports = module.exports = {
|
2022-04-04 14:13:27 -07:00
|
|
|
getRootPath,
|
2021-02-18 16:51:43 -08:00
|
|
|
checkPreconditions,
|
2020-06-05 13:27:18 +02:00
|
|
|
|
2021-02-18 16:51:43 -08:00
|
|
|
upload,
|
|
|
|
|
exists,
|
|
|
|
|
download,
|
|
|
|
|
downloadDir,
|
|
|
|
|
copy,
|
2017-09-17 18:50:29 -07:00
|
|
|
|
2021-02-18 16:51:43 -08:00
|
|
|
listDir,
|
2018-07-27 14:29:07 -07:00
|
|
|
|
2021-02-18 16:51:43 -08:00
|
|
|
remove,
|
|
|
|
|
removeDir,
|
2017-05-19 14:50:29 -07:00
|
|
|
|
2021-10-11 17:45:35 +02:00
|
|
|
remount,
|
|
|
|
|
|
2021-02-18 16:51:43 -08:00
|
|
|
testConfig,
|
|
|
|
|
removePrivateFields,
|
|
|
|
|
injectPrivateFields
|
2017-05-19 14:50:29 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var assert = require('assert'),
|
2019-12-04 11:17:42 -08:00
|
|
|
BoxError = require('../boxerror.js'),
|
2020-06-08 16:25:00 +02:00
|
|
|
DataLayout = require('../datalayout.js'),
|
2017-10-04 11:00:30 -07:00
|
|
|
debug = require('debug')('box:storage/noop'),
|
|
|
|
|
EventEmitter = require('events');
|
2017-05-19 14:50:29 -07:00
|
|
|
|
2022-04-04 14:13:27 -07:00
|
|
|
function getRootPath(apiConfig) {
|
2020-06-05 13:27:18 +02:00
|
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-08 16:25:00 +02:00
|
|
|
function checkPreconditions(apiConfig, dataLayout, callback) {
|
|
|
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
|
|
|
assert(dataLayout instanceof DataLayout, 'dataLayout must be a DataLayout');
|
|
|
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
|
|
|
|
|
|
callback(null);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-20 09:57:16 -07:00
|
|
|
function upload(apiConfig, backupFilePath, sourceStream, callback) {
|
2017-05-19 14:50:29 -07:00
|
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
2017-09-19 20:40:38 -07:00
|
|
|
assert.strictEqual(typeof backupFilePath, 'string');
|
2017-09-20 09:57:16 -07:00
|
|
|
assert.strictEqual(typeof sourceStream, 'object');
|
2017-05-19 14:50:29 -07:00
|
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
|
|
2017-09-20 09:57:16 -07:00
|
|
|
debug('upload: %s', backupFilePath);
|
2017-05-19 14:50:29 -07:00
|
|
|
|
2017-10-02 20:08:00 -07:00
|
|
|
callback(null);
|
2017-05-19 14:50:29 -07:00
|
|
|
}
|
|
|
|
|
|
2021-02-18 16:51:43 -08:00
|
|
|
function exists(apiConfig, backupFilePath, callback) {
|
|
|
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
|
|
|
assert.strictEqual(typeof backupFilePath, 'string');
|
|
|
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
|
|
|
|
|
|
debug('exists: %s', backupFilePath);
|
|
|
|
|
|
|
|
|
|
callback(null, false);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-20 09:57:16 -07:00
|
|
|
function download(apiConfig, backupFilePath, callback) {
|
2017-05-19 14:50:29 -07:00
|
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
2017-09-20 09:57:16 -07:00
|
|
|
assert.strictEqual(typeof backupFilePath, 'string');
|
2017-05-19 14:50:29 -07:00
|
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
|
|
2017-09-20 09:57:16 -07:00
|
|
|
debug('download: %s', backupFilePath);
|
2017-05-19 14:50:29 -07:00
|
|
|
|
2019-12-04 11:17:42 -08:00
|
|
|
callback(new BoxError(BoxError.NOT_IMPLEMENTED, 'Cannot download from noop backend'));
|
2017-05-19 14:50:29 -07:00
|
|
|
}
|
|
|
|
|
|
2018-07-27 14:29:07 -07:00
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-10 20:23:04 -07:00
|
|
|
function downloadDir(apiConfig, backupFilePath, destDir) {
|
2017-09-23 14:27:35 -07:00
|
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
|
|
|
assert.strictEqual(typeof backupFilePath, 'string');
|
|
|
|
|
assert.strictEqual(typeof destDir, 'string');
|
|
|
|
|
|
2017-10-10 20:23:04 -07:00
|
|
|
var events = new EventEmitter();
|
|
|
|
|
process.nextTick(function () {
|
|
|
|
|
debug('downloadDir: %s -> %s', backupFilePath, destDir);
|
2017-09-23 14:27:35 -07:00
|
|
|
|
2019-12-04 11:17:42 -08:00
|
|
|
events.emit('done', new BoxError(BoxError.NOT_IMPLEMENTED, 'Cannot download from noop backend'));
|
2017-10-10 20:23:04 -07:00
|
|
|
});
|
|
|
|
|
return events;
|
2017-09-23 14:27:35 -07:00
|
|
|
}
|
|
|
|
|
|
2017-10-04 11:00:30 -07:00
|
|
|
function copy(apiConfig, oldFilePath, newFilePath) {
|
2017-05-19 14:50:29 -07:00
|
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
2017-09-19 20:40:38 -07:00
|
|
|
assert.strictEqual(typeof oldFilePath, 'string');
|
|
|
|
|
assert.strictEqual(typeof newFilePath, 'string');
|
2017-05-19 14:50:29 -07:00
|
|
|
|
2017-09-19 20:40:38 -07:00
|
|
|
debug('copy: %s -> %s', oldFilePath, newFilePath);
|
2017-05-19 14:50:29 -07:00
|
|
|
|
2017-10-04 11:00:30 -07:00
|
|
|
var events = new EventEmitter();
|
|
|
|
|
process.nextTick(function () { events.emit('done', null); });
|
|
|
|
|
return events;
|
2017-05-19 14:50:29 -07:00
|
|
|
}
|
|
|
|
|
|
2017-09-27 17:34:49 -07:00
|
|
|
function remove(apiConfig, filename, callback) {
|
|
|
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
|
|
|
assert.strictEqual(typeof filename, 'string');
|
|
|
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
|
|
|
|
|
|
debug('remove: %s', filename);
|
|
|
|
|
|
2017-10-02 20:08:00 -07:00
|
|
|
callback(null);
|
2017-09-27 17:34:49 -07:00
|
|
|
}
|
|
|
|
|
|
2017-10-10 20:23:04 -07:00
|
|
|
function removeDir(apiConfig, pathPrefix) {
|
2017-05-19 14:50:29 -07:00
|
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
2017-09-23 11:09:36 -07:00
|
|
|
assert.strictEqual(typeof pathPrefix, 'string');
|
2017-05-19 14:50:29 -07:00
|
|
|
|
2017-09-27 17:34:49 -07:00
|
|
|
debug('removeDir: %s', pathPrefix);
|
2017-05-19 14:50:29 -07:00
|
|
|
|
2017-10-10 20:23:04 -07:00
|
|
|
var events = new EventEmitter();
|
|
|
|
|
process.nextTick(function () { events.emit('done', null); });
|
|
|
|
|
return events;
|
2017-05-19 14:50:29 -07:00
|
|
|
}
|
|
|
|
|
|
2021-10-11 17:45:35 +02:00
|
|
|
function remount(apiConfig, callback) {
|
|
|
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
|
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
|
|
|
|
|
|
callback(null);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-19 14:50:29 -07:00
|
|
|
function testConfig(apiConfig, callback) {
|
|
|
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
|
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
|
|
2017-10-02 20:08:00 -07:00
|
|
|
callback(null);
|
2017-05-19 14:50:29 -07:00
|
|
|
}
|
|
|
|
|
|
2019-02-09 18:08:10 -08:00
|
|
|
function removePrivateFields(apiConfig) {
|
|
|
|
|
return apiConfig;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-04 11:17:42 -08:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
2019-02-09 18:08:10 -08:00
|
|
|
function injectPrivateFields(newConfig, currentConfig) {
|
|
|
|
|
}
|