Add backuptask.js to work with new storage interface

This commit is contained in:
Johannes Zellner
2017-04-11 11:00:55 +02:00
parent 798c2ff921
commit 7fdf491815
11 changed files with 2885 additions and 351 deletions

View File

@@ -3,7 +3,6 @@
exports = module.exports = {
get: get,
create: create,
createDownloadUrl: createDownloadUrl,
download: download
};
@@ -44,22 +43,13 @@ function create(req, res, next) {
});
}
function createDownloadUrl(req, res, next) {
assert.strictEqual(typeof req.params.backupId, 'string');
backups.getRestoreUrl(req.params.backupId, function (error, result) {
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(200, result));
});
}
function download(req, res, next) {
assert.strictEqual(typeof req.params.backupId, 'string');
backups.getLocalDownloadPath(req.params.backupId, function (error, result) {
backups.getDownloadStream(req.params.backupId, function (error, result) {
if (error && error.reason === BackupsError.NOT_FOUND) return next(new HttpError(404, error.message));
if (error) return next(new HttpError(500, error));
res.sendFile(result);
result.pipe(res);
});
}