storage: check volume status

This commit is contained in:
Girish Ramakrishnan
2022-06-03 10:17:34 -07:00
parent 4bee30dd83
commit 7dba294961
2 changed files with 11 additions and 6 deletions

View File

@@ -436,10 +436,14 @@ async function setStorage(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
assert.strictEqual(typeof req.app, 'object');
if (req.body.storageVolumeId !== null && typeof req.body.storageVolumeId !== 'string') return next(new HttpError(400, 'storageVolumeId must be a string'));
if (req.body.storageVolumePrefix !== null && typeof req.body.storageVolumePrefix !== 'string') return next(new HttpError(400, 'storageVolumePrefix must be a string'));
const { storageVolumeId, storageVolumePrefix } = req.body;
const [error, result] = await safe(apps.setStorage(req.app, req.body.storageVolumeId, req.body.storageVolumePrefix, AuditSource.fromRequest(req)));
if (storageVolumeId !== null) {
if (typeof storageVolumeId !== 'string') return next(new HttpError(400, 'storageVolumeId must be a string'));
if (typeof storageVolumePrefix !== 'string') return next(new HttpError(400, 'storageVolumePrefix must be a string'));
}
const [error, result] = await safe(apps.setStorage(req.app, storageVolumeId, storageVolumePrefix, AuditSource.fromRequest(req)));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(202, { taskId: result.taskId }));