diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/DokanyVolume.java b/main/commons/src/main/java/org/cryptomator/common/vaults/DokanyVolume.java index 87009dcf7..c20538e5d 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/DokanyVolume.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/DokanyVolume.java @@ -30,6 +30,7 @@ public class DokanyVolume implements Volume { private final MountFactory mountFactory; private final WindowsDriveLetters windowsDriveLetters; private Mount mount; + private Path mountPoint; @Inject public DokanyVolume(VaultSettings vaultSettings, ExecutorService executorService, WindowsDriveLetters windowsDriveLetters) { @@ -45,19 +46,19 @@ public class DokanyVolume implements Volume { @Override public void mount(CryptoFileSystem fs, String mountFlags) throws VolumeException, IOException { - Path mountPath = getMountPoint(); + this.mountPoint = determineMountPoint(); String mountName = vaultSettings.mountName().get(); try { - this.mount = mountFactory.mount(fs.getPath("/"), mountPath, mountName, FS_TYPE_NAME, mountFlags.strip()); + this.mount = mountFactory.mount(fs.getPath("/"), mountPoint, mountName, FS_TYPE_NAME, mountFlags.strip()); } catch (MountFailedException e) { if (vaultSettings.getIndividualMountPath().isPresent()) { - LOG.warn("Failed to mount vault into {}. Is this directory currently accessed by another process (e.g. Windows Explorer)?", mountPath); + LOG.warn("Failed to mount vault into {}. Is this directory currently accessed by another process (e.g. Windows Explorer)?", mountPoint); } throw new VolumeException("Unable to mount Filesystem", e); } } - private Path getMountPoint() throws VolumeException, IOException { + private Path determineMountPoint() throws VolumeException, IOException { Optional optionalCustomMountPoint = vaultSettings.getIndividualMountPath(); if (optionalCustomMountPoint.isPresent()) { Path customMountPoint = Paths.get(optionalCustomMountPoint.get()); @@ -99,6 +100,11 @@ public class DokanyVolume implements Volume { mount.close(); } + @Override + public Optional getMountPointSafe() { + return Optional.ofNullable(mountPoint); + } + public static boolean isSupportedStatic() { return MountFactory.isApplicable(); } diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/FuseVolume.java b/main/commons/src/main/java/org/cryptomator/common/vaults/FuseVolume.java index e5330a1ad..05663d519 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/FuseVolume.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/FuseVolume.java @@ -100,8 +100,7 @@ public class FuseVolume implements Volume { try { Mounter mounter = FuseMountFactory.getMounter(); EnvironmentVariables envVars = EnvironmentVariables.create() // - .withFlags(splitFlags(mountFlags)) - .withMountPoint(mountPoint) // + .withFlags(splitFlags(mountFlags)).withMountPoint(mountPoint) // .build(); this.fuseMnt = mounter.mount(root, envVars); } catch (CommandFailedException e) { @@ -166,6 +165,11 @@ public class FuseVolume implements Volume { return FuseVolume.isSupportedStatic(); } + @Override + public Optional getMountPointSafe() { + return Optional.ofNullable(mountPoint); + } + public static boolean isSupportedStatic() { return (SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_LINUX) && FuseMountFactory.isFuseSupported(); } diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java b/main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java index c5bb75b5a..981afbee8 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java @@ -58,6 +58,7 @@ public class Vault { private final StringBinding defaultMountFlags; private final AtomicReference cryptoFileSystem = new AtomicReference<>(); private final ObjectProperty state = new SimpleObjectProperty(State.LOCKED); + private final ObjectProperty accessPoint = new SimpleObjectProperty<>(Path.of("")); private final StringBinding displayableName; private final StringBinding displayablePath; private final BooleanBinding locked; @@ -81,6 +82,7 @@ public class Vault { this.locked = Bindings.createBooleanBinding(this::isLocked, state); this.processing = Bindings.createBooleanBinding(this::isProcessing, state); this.unlocked = Bindings.createBooleanBinding(this::isUnlocked, state); + this.state.addListener(this::setAccessPoint); } // ****************************************************************************** @@ -219,6 +221,22 @@ public class Vault { return p.getFileName().toString(); } + public ObjectProperty accessPointProperty() { + return accessPoint; + } + + public Path getAccessPoint() { + return accessPoint.get(); + } + + private void setAccessPoint(Observable obs) { + if (this.getState() == State.UNLOCKED) { + accessPoint.setValue(volume.getMountPointSafe().get()); + } else { + accessPoint.setValue(Path.of("")); + } + } + public StringBinding displayablePathProperty() { return displayablePath; } diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/Volume.java b/main/commons/src/main/java/org/cryptomator/common/vaults/Volume.java index 6b36d6d45..21515a8f0 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/Volume.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/Volume.java @@ -4,6 +4,8 @@ import org.cryptomator.common.settings.VolumeImpl; import org.cryptomator.cryptofs.CryptoFileSystem; import java.io.IOException; +import java.nio.file.Path; +import java.util.Optional; import java.util.stream.Stream; /** @@ -28,6 +30,8 @@ public interface Volume { void unmount() throws VolumeException; + Optional getMountPointSafe(); + // optional forced unmounting: default boolean supportsForcedUnmount() { diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/WebDavVolume.java b/main/commons/src/main/java/org/cryptomator/common/vaults/WebDavVolume.java index ee682c9f2..6ff43a6b6 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/WebDavVolume.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/WebDavVolume.java @@ -13,6 +13,8 @@ import javax.inject.Inject; import javax.inject.Provider; import java.net.InetAddress; import java.net.UnknownHostException; +import java.nio.file.Path; +import java.util.Optional; public class WebDavVolume implements Volume { @@ -25,6 +27,7 @@ public class WebDavVolume implements Volume { private WebDavServer server; private WebDavServletController servlet; private Mounter.Mount mount; + private Path mountPoint; @Inject public WebDavVolume(Provider serverProvider, VaultSettings vaultSettings, Settings settings) { @@ -93,6 +96,11 @@ public class WebDavVolume implements Volume { cleanup(); } + @Override + public Optional getMountPointSafe() { + return Optional.ofNullable(mountPoint); + } + private String getLocalhostAliasOrNull() { try { InetAddress alias = InetAddress.getByName(LOCALHOST_ALIAS); diff --git a/main/ui/src/main/resources/fxml/vault_detail.fxml b/main/ui/src/main/resources/fxml/vault_detail.fxml index d5349a562..ffff26336 100644 --- a/main/ui/src/main/resources/fxml/vault_detail.fxml +++ b/main/ui/src/main/resources/fxml/vault_detail.fxml @@ -57,7 +57,7 @@