Added MountPointRequirement-Enum

Added MountPointRequirement-Enum and added method getMountPointRequirement() to Volume (and all implementing classes) to query the requirment for the specific VolumeProvider.
This commit is contained in:
JaniruTEC
2020-07-20 22:01:10 +02:00
parent 341a98848d
commit dae2814b0f
5 changed files with 53 additions and 0 deletions

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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;
}

View File

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

View File

@@ -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);