Files
cloudron-box/src/storage/noop.js
T

125 lines
3.2 KiB
JavaScript
Raw Normal View History

2017-05-19 14:50:29 -07:00
'use strict';
exports = module.exports = {
2022-10-02 16:26:27 +02:00
getBackupRootPath,
getProviderStatus,
getAvailableSize,
upload,
exists,
download,
copy,
2017-09-17 18:50:29 -07:00
listDir,
2018-07-27 14:29:07 -07:00
remove,
removeDir,
2017-05-19 14:50:29 -07:00
remount,
testConfig,
removePrivateFields,
injectPrivateFields
2017-05-19 14:50:29 -07:00
};
2022-04-14 07:40:19 -05:00
const assert = require('assert'),
2019-12-04 11:17:42 -08:00
BoxError = require('../boxerror.js'),
debug = require('debug')('box:storage/noop');
2017-05-19 14:50:29 -07:00
2022-10-02 16:26:27 +02:00
function getBackupRootPath(apiConfig) {
assert.strictEqual(typeof apiConfig, 'object');
return '';
}
async function getProviderStatus(apiConfig) {
2020-06-08 16:25:00 +02:00
assert.strictEqual(typeof apiConfig, 'object');
return { state: 'active' };
}
async function getAvailableSize(apiConfig) {
assert.strictEqual(typeof apiConfig, 'object');
return Number.POSITIVE_INFINITY;
2020-06-08 16:25:00 +02: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');
assert.strictEqual(typeof sourceStream, 'object');
2017-05-19 14:50:29 -07:00
assert.strictEqual(typeof callback, 'function');
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
}
2022-04-14 08:07:03 -05:00
async function exists(apiConfig, backupFilePath) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof backupFilePath, 'string');
2022-04-14 08:07:03 -05:00
debug(`exists: ${backupFilePath}`);
2022-04-14 08:07:03 -05:00
return false;
}
function download(apiConfig, backupFilePath, callback) {
2017-05-19 14:50:29 -07:00
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof backupFilePath, 'string');
2017-05-19 14:50:29 -07:00
assert.strictEqual(typeof callback, 'function');
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();
}
2022-04-30 16:01:42 -07:00
async function copy(apiConfig, oldFilePath, newFilePath, progressCallback) {
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');
2022-04-30 16:01:42 -07:00
assert.strictEqual(typeof progressCallback, 'function');
2017-05-19 14:50:29 -07:00
2022-04-30 16:01:42 -07:00
debug(`copy: ${oldFilePath} -> ${newFilePath}`);
2017-05-19 14:50:29 -07:00
}
2022-04-14 16:07:01 -05:00
async function remove(apiConfig, filename) {
2017-09-27 17:34:49 -07:00
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof filename, 'string');
2022-04-14 16:07:01 -05:00
debug(`remove: ${filename}`);
2017-09-27 17:34:49 -07:00
}
2022-04-30 16:35:39 -07:00
async function removeDir(apiConfig, pathPrefix, progressCallback) {
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');
2022-04-14 16:07:01 -05:00
assert.strictEqual(typeof progressCallback, 'function');
2017-05-19 14:50:29 -07:00
2022-04-14 16:07:01 -05:00
debug(`removeDir: ${pathPrefix}`);
2017-05-19 14:50:29 -07:00
}
2022-04-14 07:43:43 -05:00
async function remount(apiConfig) {
assert.strictEqual(typeof apiConfig, 'object');
}
2022-04-14 07:59:50 -05:00
async function testConfig(apiConfig) {
2017-05-19 14:50:29 -07:00
assert.strictEqual(typeof apiConfig, 'object');
}
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) {
}