Browse Source

Added MountPointRequirement-Enum

Added MountPointRequirement-Enum and added method getMountPointRequirement() to Volume (and all implementing classes) to query the requirment for the specific VolumeProvider.
JaniruTEC 4 năm trước cách đây
mục cha
commit
dae2814b0f

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

@@ -106,6 +106,11 @@ public class DokanyVolume implements Volume {
 		return Optional.ofNullable(mountPoint);
 	}
 
+	@Override
+	public MountPointRequirement getMountPointRequirement() {
+		return MountPointRequirement.EMPTY_MOUNT_POINT;
+	}
+
 	public static boolean isSupportedStatic() {
 		return MountFactory.isApplicable();
 	}

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

@@ -182,6 +182,11 @@ public class FuseVolume implements Volume {
 		return Optional.ofNullable(mountPoint);
 	}
 
+	@Override
+	public MountPointRequirement getMountPointRequirement() {
+		return SystemUtils.IS_OS_WINDOWS ? MountPointRequirement.PARENT_NO_MOUNT_POINT : MountPointRequirement.EMPTY_MOUNT_POINT;
+	}
+
 	public static boolean isSupportedStatic() {
 		return FuseMountFactory.isFuseSupported();
 	}

+ 36 - 0
main/commons/src/main/java/org/cryptomator/common/vaults/MountPointRequirement.java

@@ -0,0 +1,36 @@
+package org.cryptomator.common.vaults;
+
+/**
+ * Enumeration used to indicate the requirements for mounting a vault
+ * using a specific {@link Volume VolumeProvider}, e.g. {@link FuseVolume}.
+ */
+public enum MountPointRequirement {
+
+	/**
+	 * No Mountpoint on the local filesystem required. (e.g. WebDAV)
+	 */
+	NONE,
+
+	/**
+	 * A parent folder is required, but the actual Mountpoint must not exist.
+	 */
+	PARENT_NO_MOUNT_POINT,
+
+	/**
+	 * A parent folder is required, but the actual Mountpoint may exist.
+	 */
+	PARENT_OPT_MOUNT_POINT,
+
+	/**
+	 * The actual Mountpoint must exist, must be empty and the parent must exist aswell.
+	 */
+	EMPTY_MOUNT_POINT;
+
+//	/**
+//	 * The actual Mountpoint must exist and may contain files.
+//	 */
+//	MOUNT_POINT;
+
+
+
+}

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

@@ -32,6 +32,8 @@ public interface Volume {
 
 	Optional<Path> getMountPoint();
 
+	MountPointRequirement getMountPointRequirement();
+
 	// optional forced unmounting:
 
 	default boolean supportsForcedUnmount() {

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

@@ -101,6 +101,11 @@ public class WebDavVolume implements Volume {
 		return Optional.ofNullable(mountPoint);
 	}
 
+	@Override
+	public MountPointRequirement getMountPointRequirement() {
+		return MountPointRequirement.NONE;
+	}
+
 	private String getLocalhostAliasOrNull() {
 		try {
 			InetAddress alias = InetAddress.getByName(LOCALHOST_ALIAS);