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

100 lines
2.8 KiB
JavaScript
Raw Normal View History

2017-05-19 14:50:29 -07:00
'use strict';
exports = module.exports = {
2017-09-17 18:50:29 -07:00
upload: upload,
download: download,
2017-09-23 14:27:35 -07:00
downloadDir: downloadDir,
2017-09-17 18:50:29 -07:00
copy: copy,
2017-09-23 11:09:36 -07:00
remove: remove,
2017-09-27 17:34:49 -07:00
removeDir: removeDir,
2017-05-19 14:50:29 -07:00
backupDone: backupDone,
testConfig: testConfig
};
var assert = require('assert'),
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
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
}
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
callback(new Error('Cannot download from noop backend'));
2017-05-19 14:50:29 -07:00
}
2017-09-23 14:27:35 -07:00
function downloadDir(apiConfig, backupFilePath, destDir, callback) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof backupFilePath, 'string');
assert.strictEqual(typeof destDir, 'string');
assert.strictEqual(typeof callback, 'function');
debug('downloadDir: %s -> %s', backupFilePath, destDir);
2017-10-02 20:08:00 -07:00
callback(new Error('Cannot download from noop backend'));
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
}
function removeDir(apiConfig, pathPrefix, callback) {
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
assert.strictEqual(typeof callback, 'function');
2017-09-27 17:34:49 -07:00
debug('removeDir: %s', pathPrefix);
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
}
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
}
2017-09-26 12:28:33 -07:00
function backupDone(apiConfig, backupId, appBackupIds, callback) {
assert.strictEqual(typeof apiConfig, 'object');
2017-05-19 14:50:29 -07:00
assert.strictEqual(typeof backupId, 'string');
assert(Array.isArray(appBackupIds));
assert.strictEqual(typeof callback, 'function');
2017-10-02 20:08:00 -07:00
callback(null);
2017-05-19 14:50:29 -07:00
}