The storage backends dont need a backup listing function
This commit is contained in:
@@ -4,8 +4,6 @@ exports = module.exports = {
|
||||
getBoxBackupDetails: getBoxBackupDetails,
|
||||
getAppBackupDetails: getAppBackupDetails,
|
||||
|
||||
getAllPaged: getAllPaged,
|
||||
|
||||
getRestoreUrl: getRestoreUrl,
|
||||
|
||||
copyObject: copyObject
|
||||
@@ -14,8 +12,7 @@ exports = module.exports = {
|
||||
var assert = require('assert'),
|
||||
AWS = require('aws-sdk'),
|
||||
config = require('../config.js'),
|
||||
superagent = require('superagent'),
|
||||
util = require('util');
|
||||
superagent = require('superagent');
|
||||
|
||||
function getBackupCredentials(apiConfig, callback) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
@@ -83,22 +80,6 @@ function getAppBackupDetails(apiConfig, appId, dataId, configId, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function getAllPaged(apiConfig, page, perPage, callback) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
assert.strictEqual(typeof page, 'number');
|
||||
assert.strictEqual(typeof perPage, 'number');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
var url = config.apiServerOrigin() + '/api/v1/boxes/' + config.fqdn() + '/backups';
|
||||
superagent.get(url).query({ token: apiConfig.token }).timeout(30 * 1000).end(function (error, result) {
|
||||
if (error && !error.response) return callback(error);
|
||||
if (result.statusCode !== 200) return callback(new Error(result.text));
|
||||
if (!result.body || !util.isArray(result.body.backups)) return callback(new Error('Unexpected response'));
|
||||
|
||||
return callback(null, result.body.backups);
|
||||
});
|
||||
}
|
||||
|
||||
function getRestoreUrl(apiConfig, filename, callback) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
assert.strictEqual(typeof filename, 'string');
|
||||
|
||||
@@ -4,8 +4,6 @@ exports = module.exports = {
|
||||
getBoxBackupDetails: getBoxBackupDetails,
|
||||
getAppBackupDetails: getAppBackupDetails,
|
||||
|
||||
getAllPaged: getAllPaged,
|
||||
|
||||
getRestoreUrl: getRestoreUrl,
|
||||
|
||||
copyObject: copyObject
|
||||
@@ -47,31 +45,6 @@ function getAppBackupDetails(apiConfig, appId, dataId, configId, callback) {
|
||||
callback(null, details);
|
||||
}
|
||||
|
||||
function getAllPaged(apiConfig, page, perPage, callback) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
assert.strictEqual(typeof page, 'number');
|
||||
assert.strictEqual(typeof perPage, 'number');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
var backupFolder = apiConfig.backupFolder || FALLBACK_BACKUP_FOLDER;
|
||||
|
||||
fs.readdir(backupFolder, function (error, entries) {
|
||||
if (error) return callback(error);
|
||||
|
||||
var results = entries.map(function (entry) {
|
||||
return {
|
||||
creationTime: Date.now(), // FIXME extract from filename or stat?
|
||||
restoreKey: entry,
|
||||
dependsOn: [] // FIXME empty dependsOn is wrong and version property is missing!!
|
||||
};
|
||||
});
|
||||
|
||||
results.sort(function (a, b) { return a.creationTime < b.creationTime; });
|
||||
|
||||
return callback(null, results);
|
||||
});
|
||||
}
|
||||
|
||||
function getRestoreUrl(apiConfig, filename, callback) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
assert.strictEqual(typeof filename, 'string');
|
||||
|
||||
@@ -10,8 +10,6 @@ exports = module.exports = {
|
||||
getBoxBackupDetails: getBoxBackupDetails,
|
||||
getAppBackupDetails: getAppBackupDetails,
|
||||
|
||||
getAllPaged: getAllPaged,
|
||||
|
||||
getRestoreUrl: getRestoreUrl,
|
||||
|
||||
copyObject: copyObject
|
||||
@@ -43,18 +41,6 @@ function getAppBackupDetails(apiConfig, appId, dataId, configId, callback) {
|
||||
callback(new Error('not implemented'));
|
||||
}
|
||||
|
||||
function getAllPaged(apiConfig, page, perPage, callback) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
assert.strictEqual(typeof page, 'number');
|
||||
assert.strictEqual(typeof perPage, 'number');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
// Result: { backupScriptArguments: [ { creationTime: <timestamp> }, restoreKey: <filename>, dependsOn: [] ] }
|
||||
// The resulting array consists of objects representing each backup
|
||||
|
||||
callback(new Error('not implemented'));
|
||||
}
|
||||
|
||||
function getRestoreUrl(apiConfig, filename, callback) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
assert.strictEqual(typeof filename, 'string');
|
||||
|
||||
@@ -4,8 +4,6 @@ exports = module.exports = {
|
||||
getBoxBackupDetails: getBoxBackupDetails,
|
||||
getAppBackupDetails: getAppBackupDetails,
|
||||
|
||||
getAllPaged: getAllPaged,
|
||||
|
||||
getRestoreUrl: getRestoreUrl,
|
||||
|
||||
copyObject: copyObject
|
||||
@@ -65,41 +63,6 @@ function getAppBackupDetails(apiConfig, appId, dataId, configId, callback) {
|
||||
callback(null, details);
|
||||
}
|
||||
|
||||
function getAllPaged(apiConfig, page, perPage, callback) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
assert.strictEqual(typeof page, 'number');
|
||||
assert.strictEqual(typeof perPage, 'number');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
getBackupCredentials(apiConfig, function (error, credentials) {
|
||||
if (error) return callback(error);
|
||||
|
||||
var s3 = new AWS.S3(credentials);
|
||||
|
||||
var params = {
|
||||
Bucket: apiConfig.bucket,
|
||||
EncodingType: 'url',
|
||||
Prefix: apiConfig.prefix + '/backup_'
|
||||
};
|
||||
|
||||
s3.listObjects(params, function (error, data) {
|
||||
if (error) return callback(error);
|
||||
|
||||
var results = data.Contents.map(function (backup) {
|
||||
return {
|
||||
creationTime: backup.LastModified,
|
||||
restoreKey: backup.Key.slice(apiConfig.prefix.length + 1),
|
||||
dependsOn: [] // FIXME empty dependsOn is wrong and version property is missing!!
|
||||
};
|
||||
});
|
||||
|
||||
results.sort(function (a, b) { return a.creationTime < b.creationTime; });
|
||||
|
||||
return callback(null, results);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getRestoreUrl(apiConfig, filename, callback) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
assert.strictEqual(typeof filename, 'string');
|
||||
|
||||
Reference in New Issue
Block a user