volumes: update route
This commit is contained in:
@@ -5,7 +5,7 @@ exports = module.exports = {
|
||||
get,
|
||||
del,
|
||||
list,
|
||||
setMountConfig,
|
||||
update,
|
||||
getMountStatus,
|
||||
};
|
||||
|
||||
@@ -136,7 +136,7 @@ async function removeMountFile(volume) {
|
||||
await safe(shell.promises.sudo('generateMountFile', [ RM_MOUNT_CMD, volume.hostPath ], {})); // ignore any error
|
||||
}
|
||||
|
||||
async function setMountConfig(volume, mountType, mountOptions) {
|
||||
async function update(volume, mountType, mountOptions) {
|
||||
assert.strictEqual(typeof volume, 'object');
|
||||
assert.strictEqual(typeof mountType, 'string');
|
||||
assert.strictEqual(typeof mountOptions, 'object');
|
||||
@@ -144,8 +144,14 @@ async function setMountConfig(volume, mountType, mountOptions) {
|
||||
let error = validateMountOptions(mountType, mountOptions);
|
||||
if (error) throw error;
|
||||
|
||||
if (mountType === 'noop') {
|
||||
await safe(removeMountFile(Object.assign({}, volume, { mountType, mountOptions })));
|
||||
} else {
|
||||
await safe(writeMountFile(Object.assign({}, volume, { mountType, mountOptions })));
|
||||
}
|
||||
|
||||
let result;
|
||||
[error, result] = await safe(database.query('UPDATE volumes SET mountType=? AND mountOptionsJson=? WHERE id=?', [ mountType, JSON.stringify(mountOptions), volume.id ]));
|
||||
[error, result] = await safe(database.query('UPDATE volumes SET mountType=?, mountOptionsJson=? WHERE id=?', [ mountType, JSON.stringify(mountOptions), volume.id ]));
|
||||
if (error) throw error;
|
||||
if (result.affectedRows !== 1) throw new BoxError(BoxError.NOT_FOUND, 'Volume not found');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user