|
@@ -6,8 +6,8 @@ import org.cryptomator.common.mountpoint.InvalidMountPointException;
|
|
|
import org.cryptomator.common.mountpoint.MountPointChooser;
|
|
|
import org.cryptomator.common.settings.VolumeImpl;
|
|
|
import org.cryptomator.cryptofs.CryptoFileSystem;
|
|
|
-import org.cryptomator.frontend.fuse.mount.CommandFailedException;
|
|
|
import org.cryptomator.frontend.fuse.mount.EnvironmentVariables;
|
|
|
+import org.cryptomator.frontend.fuse.mount.FuseMountException;
|
|
|
import org.cryptomator.frontend.fuse.mount.FuseMountFactory;
|
|
|
import org.cryptomator.frontend.fuse.mount.FuseNotSupportedException;
|
|
|
import org.cryptomator.frontend.fuse.mount.Mount;
|
|
@@ -20,8 +20,7 @@ import javax.inject.Named;
|
|
|
import java.nio.file.Path;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
-import java.util.concurrent.CompletionStage;
|
|
|
+import java.util.function.Consumer;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
public class FuseVolume extends AbstractVolume {
|
|
@@ -37,14 +36,12 @@ public class FuseVolume extends AbstractVolume {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public CompletionStage<Void> mount(CryptoFileSystem fs, String mountFlags) throws InvalidMountPointException, VolumeException {
|
|
|
+ public void mount(CryptoFileSystem fs, String mountFlags, Consumer<Throwable> onExitAction) throws InvalidMountPointException, VolumeException {
|
|
|
this.mountPoint = determineMountPoint();
|
|
|
-
|
|
|
- mount(fs.getPath("/"), mountFlags);
|
|
|
- return CompletableFuture.failedFuture(new IllegalStateException("THOU SHOULD NOT PASS")); //FIXME
|
|
|
+ mount(fs.getPath("/"), mountFlags, onExitAction);
|
|
|
}
|
|
|
|
|
|
- private void mount(Path root, String mountFlags) throws VolumeException {
|
|
|
+ private void mount(Path root, String mountFlags, Consumer<Throwable> onExitAction) throws VolumeException {
|
|
|
try {
|
|
|
Mounter mounter = FuseMountFactory.getMounter();
|
|
|
EnvironmentVariables envVars = EnvironmentVariables.create() //
|
|
@@ -52,8 +49,8 @@ public class FuseVolume extends AbstractVolume {
|
|
|
.withMountPoint(mountPoint) //
|
|
|
.withFileNameTranscoder(mounter.defaultFileNameTranscoder()) //
|
|
|
.build();
|
|
|
- this.mount = mounter.mount(root, envVars);
|
|
|
- } catch (CommandFailedException | FuseNotSupportedException e) {
|
|
|
+ this.mount = mounter.mount(root, envVars, onExitAction);
|
|
|
+ } catch ( FuseMountException | FuseNotSupportedException e) {
|
|
|
throw new VolumeException("Unable to mount Filesystem", e);
|
|
|
}
|
|
|
}
|
|
@@ -94,8 +91,7 @@ public class FuseVolume extends AbstractVolume {
|
|
|
public synchronized void unmountForced() throws VolumeException {
|
|
|
try {
|
|
|
mount.unmountForced();
|
|
|
- mount.close();
|
|
|
- } catch (CommandFailedException e) {
|
|
|
+ } catch (FuseMountException e) {
|
|
|
throw new VolumeException(e);
|
|
|
}
|
|
|
cleanupMountPoint();
|
|
@@ -105,8 +101,7 @@ public class FuseVolume extends AbstractVolume {
|
|
|
public synchronized void unmount() throws VolumeException {
|
|
|
try {
|
|
|
mount.unmount();
|
|
|
- mount.close();
|
|
|
- } catch (CommandFailedException e) {
|
|
|
+ } catch (FuseMountException e) {
|
|
|
throw new VolumeException(e);
|
|
|
}
|
|
|
cleanupMountPoint();
|