Fix update route to use async
This commit is contained in:
@@ -177,17 +177,16 @@ async function getMemory(req, res, next) {
|
||||
next(new HttpSuccess(200, result));
|
||||
}
|
||||
|
||||
function update(req, res, next) {
|
||||
async function update(req, res, next) {
|
||||
if ('skipBackup' in req.body && typeof req.body.skipBackup !== 'boolean') return next(new HttpError(400, 'skipBackup must be a boolean'));
|
||||
|
||||
// this only initiates the update, progress can be checked via the progress route
|
||||
updater.updateToLatest(req.body, auditSource.fromRequest(req), function (error, taskId) {
|
||||
if (error && error.reason === BoxError.NOT_FOUND) return next(new HttpError(422, error.message));
|
||||
if (error && error.reason === BoxError.BAD_STATE) return next(new HttpError(409, error.message));
|
||||
if (error) return next(new HttpError(500, error));
|
||||
const [error, taskId] = await safe(updater.updateToLatest(req.body, auditSource.fromRequest(req)));
|
||||
if (error && error.reason === BoxError.NOT_FOUND) return next(new HttpError(422, error.message));
|
||||
if (error && error.reason === BoxError.BAD_STATE) return next(new HttpError(409, error.message));
|
||||
if (error) return next(new HttpError(500, error));
|
||||
|
||||
next(new HttpSuccess(202, { taskId }));
|
||||
});
|
||||
next(new HttpSuccess(202, { taskId }));
|
||||
}
|
||||
|
||||
function getUpdateInfo(req, res, next) {
|
||||
|
||||
Reference in New Issue
Block a user