Files
cloudron-box/src/storage/interface.js

103 lines
3.0 KiB
JavaScript
Raw Normal View History

2016-09-16 12:55:45 +02:00
'use strict';
// -------------------------------------------
// This file just describes the interface
//
// New backends can start from here
// -------------------------------------------
exports = module.exports = {
upload: upload,
download: download,
downloadDir: downloadDir,
copy: copy,
remove: remove,
removeDir: removeDir,
2017-01-04 16:22:58 -08:00
backupDone: backupDone,
testConfig: testConfig
2016-09-16 12:55:45 +02:00
};
var assert = require('assert'),
EventEmitter = require('events');
2016-09-16 12:55:45 +02:00
function upload(apiConfig, backupFilePath, sourceStream, callback) {
2016-09-16 12:55:45 +02:00
assert.strictEqual(typeof apiConfig, 'object');
2017-09-19 20:40:38 -07:00
assert.strictEqual(typeof backupFilePath, 'string');
assert.strictEqual(typeof sourceStream, 'object');
2016-09-16 12:55:45 +02:00
assert.strictEqual(typeof callback, 'function');
// Result: none
2016-09-16 12:55:45 +02:00
callback(new Error('not implemented'));
}
function download(apiConfig, backupFilePath, callback) {
2016-09-16 12:55:45 +02:00
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof backupFilePath, 'string');
2016-09-16 12:55:45 +02:00
assert.strictEqual(typeof callback, 'function');
// Result: download stream
callback(new Error('not implemented'));
}
2017-10-10 20:23:04 -07:00
function downloadDir(apiConfig, backupFilePath, destDir) {
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 () { events.emit('done', null); });
return events;
}
function copy(apiConfig, oldFilePath, newFilePath) {
assert.strictEqual(typeof apiConfig, 'object');
2017-09-19 20:40:38 -07:00
assert.strictEqual(typeof oldFilePath, 'string');
assert.strictEqual(typeof newFilePath, 'string');
2016-09-16 12:55:45 +02:00
var events = new EventEmitter();
process.nextTick(function () { events.emit('done', null); });
return events;
2016-09-16 12:55:45 +02:00
}
function remove(apiConfig, filename, callback) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof filename, 'string');
assert.strictEqual(typeof callback, 'function');
// Result: none. Should not error if file is not found
callback(new Error('not implemented'));
}
2017-10-10 20:23:04 -07:00
function removeDir(apiConfig, pathPrefix) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof pathPrefix, 'string');
2016-09-16 12:55:45 +02:00
// Result: none. Should not error if dir is not found
2017-10-10 20:23:04 -07:00
var events = new EventEmitter();
process.nextTick(function () { events.emit('done', new Error('not implemented')); });
return events;
2016-09-16 12:55:45 +02:00
}
function testConfig(apiConfig, callback) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof callback, 'function');
2017-04-18 14:55:22 +02:00
// Result: none - first callback argument error if config does not pass the test
callback(new Error('not implemented'));
}
2017-01-04 16:22:58 -08:00
2017-09-26 12:28:33 -07:00
function backupDone(apiConfig, backupId, appBackupIds, callback) {
assert.strictEqual(typeof apiConfig, 'object');
2017-04-21 10:31:43 +02:00
assert.strictEqual(typeof backupId, 'string');
assert(Array.isArray(appBackupIds));
2017-01-04 16:22:58 -08:00
assert.strictEqual(typeof callback, 'function');
callback(new Error('not implemented'));
}