mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-20 17:46:52 -04:00
fixes #700
This commit is contained in:
@@ -33,6 +33,7 @@ import org.apache.commons.lang3.SystemUtils;
|
||||
import org.cryptomator.common.settings.VolumeImpl;
|
||||
import org.cryptomator.common.settings.Settings;
|
||||
import org.cryptomator.ui.l10n.Localization;
|
||||
import org.cryptomator.ui.model.Volume;
|
||||
|
||||
@Singleton
|
||||
public class SettingsController implements ViewController {
|
||||
@@ -93,7 +94,7 @@ public class SettingsController implements ViewController {
|
||||
checkForUpdatesCheckbox.setSelected(settings.checkForUpdates().get() && !areUpdatesManagedExternally());
|
||||
|
||||
//NIOADAPTER
|
||||
volume.getItems().addAll(getSupportedAdapters());
|
||||
volume.getItems().addAll(Volume.getCurrentSupportedAdapters());
|
||||
volume.setValue(settings.preferredVolumeImpl().get());
|
||||
volume.setConverter(new NioAdapterImplStringConverter());
|
||||
|
||||
@@ -127,11 +128,6 @@ public class SettingsController implements ViewController {
|
||||
settings.debugMode().bind(debugModeCheckbox.selectedProperty());
|
||||
}
|
||||
|
||||
private VolumeImpl[] getSupportedAdapters() {
|
||||
// TODO: filter depending on supported drivers
|
||||
return VolumeImpl.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parent getRoot() {
|
||||
return root;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class DokanyVolume implements Volume {
|
||||
|
||||
@Override
|
||||
public boolean isSupported() {
|
||||
return MountFactory.isApplicable();
|
||||
return this.isSupportedStatic();
|
||||
}
|
||||
|
||||
//TODO: Drive letter 'A' as mount point is invalid in dokany. maybe we should do already here something against it
|
||||
@@ -42,11 +42,11 @@ public class DokanyVolume implements Volume {
|
||||
//TODO: can we assume the we have at least one free drive letter?
|
||||
|
||||
//this is a temporary fix for 'A' being an invalid drive letter
|
||||
if(!windowsDriveLetters.getAvailableDriveLetters().isEmpty()){
|
||||
if (!windowsDriveLetters.getAvailableDriveLetters().isEmpty()) {
|
||||
Iterator<Character> winDriveLetterIt = windowsDriveLetters.getAvailableDriveLetters().iterator();
|
||||
do{
|
||||
do {
|
||||
driveLetter = winDriveLetterIt.next();
|
||||
}while (winDriveLetterIt.hasNext() && driveLetter == 65);
|
||||
} while (winDriveLetterIt.hasNext() && driveLetter == 65);
|
||||
// if (!windowsDriveLetters.getAvailableDriveLetters().isEmpty()) {
|
||||
// driveLetter = windowsDriveLetters.getAvailableDriveLetters().iterator().next();
|
||||
} else {
|
||||
@@ -69,4 +69,8 @@ public class DokanyVolume implements Volume {
|
||||
public void unmount() {
|
||||
mount.close();
|
||||
}
|
||||
|
||||
public static boolean isSupportedStatic() {
|
||||
return MountFactory.isApplicable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,11 +60,10 @@ public class FuseVolume implements Volume {
|
||||
private String createDirIfNotExist(String prefix, String dirName) throws IOException {
|
||||
Path p = Paths.get(prefix, dirName + vaultSettings.getId());
|
||||
if (Files.isDirectory(p)) {
|
||||
try(DirectoryStream<Path> emptyCheck = Files.newDirectoryStream(p)){
|
||||
if(emptyCheck.iterator().hasNext()){
|
||||
try (DirectoryStream<Path> emptyCheck = Files.newDirectoryStream(p)) {
|
||||
if (emptyCheck.iterator().hasNext()) {
|
||||
throw new DirectoryNotEmptyException("Mount point is not empty.");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
LOG.info("Directory already exists and is empty. Using it as mount point.");
|
||||
return p.toString();
|
||||
}
|
||||
@@ -119,6 +118,10 @@ public class FuseVolume implements Volume {
|
||||
|
||||
@Override
|
||||
public boolean isSupported() {
|
||||
return this.isSupportedStatic();
|
||||
}
|
||||
|
||||
public static boolean isSupportedStatic() {
|
||||
return (SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_LINUX) && FuseMountFactory.isFuseSupported();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package org.cryptomator.ui.model;
|
||||
|
||||
import org.cryptomator.common.settings.VolumeImpl;
|
||||
import org.cryptomator.cryptofs.CryptoFileSystem;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Takes a Volume and usess it to mount an unlocked vault
|
||||
@@ -11,12 +13,12 @@ public interface Volume {
|
||||
|
||||
/**
|
||||
* Checks in constant time whether this volume type is supported on the system running Cryptomator.
|
||||
*
|
||||
* @return true if this volume can be mounted
|
||||
*/
|
||||
boolean isSupported();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fs
|
||||
* @throws IOException
|
||||
*/
|
||||
@@ -36,6 +38,21 @@ public interface Volume {
|
||||
throw new VolumeException("Operation not supported.");
|
||||
}
|
||||
|
||||
static VolumeImpl[] getCurrentSupportedAdapters() {
|
||||
return Stream.of(VolumeImpl.values()).filter(impl -> {
|
||||
switch (impl) {
|
||||
case WEBDAV:
|
||||
return WebDavVolume.isSupportedStatic();
|
||||
case DOKANY:
|
||||
return DokanyVolume.isSupportedStatic();
|
||||
case FUSE:
|
||||
return FuseVolume.isSupportedStatic();
|
||||
default:
|
||||
return false;//throw new IllegalStateException("Adapter not implemented.");
|
||||
}
|
||||
}).toArray(VolumeImpl[]::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception thrown when a volume-specific command such as mount/unmount/reveal failed.
|
||||
*/
|
||||
|
||||
@@ -116,11 +116,16 @@ public class WebDavVolume implements Volume {
|
||||
|
||||
@Override
|
||||
public boolean isSupported() {
|
||||
return true;
|
||||
return this.isSupportedStatic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsForcedUnmount() {
|
||||
return mount != null && mount.forced().isPresent();
|
||||
}
|
||||
|
||||
|
||||
public static boolean isSupportedStatic() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user