First attempt a temporary mountpoint
This commit is contained in:
@@ -195,6 +195,20 @@ async function tryAddMount(mount, options) {
|
||||
|
||||
if (constants.TEST) return;
|
||||
|
||||
// first try to mount at /mnt/volumes/<volumeId>-attempt
|
||||
const originalHostPath = mount.hostPath;
|
||||
mount.hostPath = originalHostPath + '-attempt';
|
||||
|
||||
const [attemptError] = await safe(shell.promises.sudo('addMount', [ ADD_MOUNT_CMD, renderMountFile(mount), options.timeout ], {}));
|
||||
if (attemptError && attemptError.code === 2) throw new BoxError(BoxError.MOUNT_ERROR, 'Failed to unmount existing mount'); // at this point, the old mount config is still there
|
||||
|
||||
const attemptStatus = await getStatus(mount.mountType, mount.hostPath);
|
||||
await removeMount(mount);
|
||||
if (attemptStatus.state !== 'active') throw new BoxError(BoxError.MOUNT_ERROR, `Failed to mount (${attemptStatus.state}): ${attemptStatus.message}`);
|
||||
|
||||
// now create the real mount
|
||||
mount.hostPath = originalHostPath;
|
||||
|
||||
const [error] = await safe(shell.promises.sudo('addMount', [ ADD_MOUNT_CMD, renderMountFile(mount), options.timeout ], {}));
|
||||
if (error && error.code === 2) throw new BoxError(BoxError.MOUNT_ERROR, 'Failed to unmount existing mount'); // at this point, the old mount config is still there
|
||||
|
||||
|
||||
Reference in New Issue
Block a user