storage: check volume status
This commit is contained in:
@@ -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 }));
|
||||
|
||||
Reference in New Issue
Block a user