diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/AbstractVolume.java b/main/commons/src/main/java/org/cryptomator/common/vaults/AbstractVolume.java index 33741730d..8b47ffe07 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/AbstractVolume.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/AbstractVolume.java @@ -4,8 +4,6 @@ import com.google.common.base.Joiner; import com.google.common.collect.ImmutableSet; import org.cryptomator.common.mountpoint.InvalidMountPointException; import org.cryptomator.common.mountpoint.MountPointChooser; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.nio.file.Path; import java.util.Optional; @@ -13,10 +11,10 @@ import java.util.Set; public abstract class AbstractVolume implements Volume { - private static final Logger LOG = LoggerFactory.getLogger(AbstractVolume.class); - private final Set choosers; + protected Path mountPoint; + //Cleanup private boolean cleanupRequired; private MountPointChooser usedChooser; @@ -25,7 +23,7 @@ public abstract class AbstractVolume implements Volume { this.choosers = choosers; } - public Path determineMountPoint() throws InvalidMountPointException { + protected Path determineMountPoint() throws InvalidMountPointException { for (MountPointChooser chooser : this.choosers) { Optional chosenPath = chooser.chooseMountPoint(); if (chosenPath.isEmpty()) { @@ -40,9 +38,14 @@ public abstract class AbstractVolume implements Volume { throw new InvalidMountPointException(String.format("No feasible MountPoint found! Tried %s", tried)); } - public void cleanupMountPoint() { + protected void cleanupMountPoint() { if (this.cleanupRequired) { this.usedChooser.cleanup(this.mountPoint); } } + + @Override + public Optional getMountPoint() { + return Optional.ofNullable(mountPoint); + } } 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 51a7dac0b..e65b3f0f9 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 @@ -12,8 +12,6 @@ import org.slf4j.LoggerFactory; import javax.inject.Inject; import javax.inject.Named; -import java.nio.file.Path; -import java.util.Optional; import java.util.Set; import java.util.concurrent.ExecutorService; @@ -27,7 +25,6 @@ public class DokanyVolume extends AbstractVolume { private final MountFactory mountFactory; private Mount mount; - private Path mountPoint; @Inject public DokanyVolume(VaultSettings vaultSettings, ExecutorService executorService, @Named("orderedValidMountPointChoosers") Set choosers) { @@ -69,11 +66,6 @@ public class DokanyVolume extends AbstractVolume { return DokanyVolume.isSupportedStatic(); } - @Override - public Optional getMountPoint() { - return Optional.ofNullable(mountPoint); - } - @Override public MountPointRequirement getMountPointRequirement() { return MountPointRequirement.EMPTY_MOUNT_POINT; 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 421471579..8f1926f4a 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 @@ -17,15 +17,13 @@ import org.slf4j.LoggerFactory; import javax.inject.Inject; import javax.inject.Named; import java.nio.file.Path; -import java.util.Optional; import java.util.Set; public class FuseVolume extends AbstractVolume { private static final Logger LOG = LoggerFactory.getLogger(FuseVolume.class); - private Mount fuseMnt; - private Path mountPoint; + private Mount mount; @Inject public FuseVolume(@Named("orderedValidMountPointChoosers") Set choosers) { @@ -45,7 +43,7 @@ public class FuseVolume extends AbstractVolume { EnvironmentVariables envVars = EnvironmentVariables.create() // .withFlags(splitFlags(mountFlags)).withMountPoint(mountPoint) // .build(); - this.fuseMnt = mounter.mount(root, envVars); + this.mount = mounter.mount(root, envVars); } catch (CommandFailedException | FuseNotSupportedException e) { throw new VolumeException("Unable to mount Filesystem", e); } @@ -58,7 +56,7 @@ public class FuseVolume extends AbstractVolume { @Override public void reveal() throws VolumeException { try { - fuseMnt.revealInFileManager(); + mount.revealInFileManager(); } catch (CommandFailedException e) { LOG.debug("Revealing the vault in file manger failed: " + e.getMessage()); throw new VolumeException(e); @@ -73,8 +71,8 @@ public class FuseVolume extends AbstractVolume { @Override public synchronized void unmountForced() throws VolumeException { try { - fuseMnt.unmountForced(); - fuseMnt.close(); + mount.unmountForced(); + mount.close(); } catch (CommandFailedException e) { throw new VolumeException(e); } @@ -84,8 +82,8 @@ public class FuseVolume extends AbstractVolume { @Override public synchronized void unmount() throws VolumeException { try { - fuseMnt.unmount(); - fuseMnt.close(); + mount.unmount(); + mount.close(); } catch (CommandFailedException e) { throw new VolumeException(e); } @@ -97,11 +95,6 @@ public class FuseVolume extends AbstractVolume { return FuseVolume.isSupportedStatic(); } - @Override - public Optional getMountPoint() { - return Optional.ofNullable(mountPoint); - } - @Override public MountPointRequirement getMountPointRequirement() { return SystemUtils.IS_OS_WINDOWS ? MountPointRequirement.PARENT_NO_MOUNT_POINT : MountPointRequirement.EMPTY_MOUNT_POINT; 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 a8e84c80c..ecdb31d88 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 @@ -27,7 +27,6 @@ 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) { @@ -98,7 +97,7 @@ public class WebDavVolume implements Volume { @Override public Optional getMountPoint() { - return Optional.ofNullable(mountPoint); + return Optional.empty(); } @Override