volumes: wait for mount during add/update

this is a better feedback mechanism for the user
This commit is contained in:
Girish Ramakrishnan
2021-05-19 09:50:50 -07:00
parent 449d6b2de4
commit 59db625ad9
4 changed files with 68 additions and 31 deletions
+4
View File
@@ -36,6 +36,8 @@ async function add(req, res, next) {
if (typeof req.body.mountType !== 'string') return next(new HttpError(400, 'mountType must be a string'));
if (typeof req.body.mountOptions !== 'object') return next(new HttpError(400, 'mountOptions must be a object'));
req.clearTimeout(); // waiting for mount can take time
const [error, id] = await safe(volumes.add(req.body, auditSource.fromRequest(req)));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(201, { id }));
@@ -67,6 +69,8 @@ async function update(req, res, next) {
if (typeof req.body.mountType !== 'string') return next(new HttpError(400, 'mountType must be a string'));
if (typeof req.body.mountOptions !== 'object') return next(new HttpError(400, 'mountOptions must be a object'));
req.clearTimeout(); // waiting for mount can take time
const [error] = await safe(volumes.update(req.resource, req.body.mountType, req.body.mountOptions));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, {}));