Sfoglia il codice sorgente

Added api for getting the implemented VolumeImpl (type) of a Volume

JaniruTEC 4 anni fa
parent
commit
22438d1eba

+ 6 - 0
main/commons/src/main/java/org/cryptomator/common/vaults/DokanyVolume.java

@@ -2,6 +2,7 @@ package org.cryptomator.common.vaults;
 
 import com.google.common.base.Strings;
 import org.cryptomator.common.settings.VaultSettings;
+import org.cryptomator.common.settings.VolumeImpl;
 import org.cryptomator.cryptofs.CryptoFileSystem;
 import org.cryptomator.frontend.dokany.Mount;
 import org.cryptomator.frontend.dokany.MountFactory;
@@ -44,6 +45,11 @@ public class DokanyVolume implements Volume {
 		return DokanyVolume.isSupportedStatic();
 	}
 
+	@Override
+	public VolumeImpl getImplementationType() {
+		return VolumeImpl.DOKANY;
+	}
+
 	@Override
 	public void mount(CryptoFileSystem fs, String mountFlags) throws VolumeException, IOException {
 		this.mountPoint = determineMountPoint();

+ 6 - 0
main/commons/src/main/java/org/cryptomator/common/vaults/FuseVolume.java

@@ -4,6 +4,7 @@ import com.google.common.base.Splitter;
 import org.apache.commons.lang3.SystemUtils;
 import org.cryptomator.common.Environment;
 import org.cryptomator.common.settings.VaultSettings;
+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;
@@ -165,6 +166,11 @@ public class FuseVolume implements Volume {
 		return FuseVolume.isSupportedStatic();
 	}
 
+	@Override
+	public VolumeImpl getImplementationType() {
+		return VolumeImpl.FUSE;
+	}
+
 	@Override
 	public Optional<Path> getMountPoint() {
 		return Optional.ofNullable(mountPoint);

+ 6 - 0
main/commons/src/main/java/org/cryptomator/common/vaults/Volume.java

@@ -20,6 +20,12 @@ public interface Volume {
 	 */
 	boolean isSupported();
 
+	/**
+	 * Gets the coresponding enum type of the {@link VolumeImpl volume implementation ("VolumeImpl")} that is implemented by this Volume.
+	 * @return the type of implementation as defined by the {@link VolumeImpl VolumeImpl enum}
+	 */
+	VolumeImpl getImplementationType();
+
 	/**
 	 * @param fs
 	 * @throws IOException

+ 6 - 0
main/commons/src/main/java/org/cryptomator/common/vaults/WebDavVolume.java

@@ -3,6 +3,7 @@ package org.cryptomator.common.vaults;
 
 import org.cryptomator.common.settings.Settings;
 import org.cryptomator.common.settings.VaultSettings;
+import org.cryptomator.common.settings.VolumeImpl;
 import org.cryptomator.cryptofs.CryptoFileSystem;
 import org.cryptomator.frontend.webdav.WebDavServer;
 import org.cryptomator.frontend.webdav.mount.MountParams;
@@ -126,6 +127,11 @@ public class WebDavVolume implements Volume {
 		return WebDavVolume.isSupportedStatic();
 	}
 
+	@Override
+	public VolumeImpl getImplementationType() {
+		return VolumeImpl.WEBDAV;
+	}
+
 	@Override
 	public boolean supportsForcedUnmount() {
 		return mount != null && mount.forced().isPresent();