mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-17 02:01:27 +00:00
empty custom mount point checks
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
*******************************************************************************/
|
||||
package org.cryptomator.common.settings;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import javafx.beans.Observable;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
@@ -20,6 +21,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Base64;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@@ -133,6 +135,14 @@ public class VaultSettings {
|
||||
return individualMountPath;
|
||||
}
|
||||
|
||||
public Optional<String> getIndividualMountPath() {
|
||||
if (usesIndividualMountPath.get()) {
|
||||
return Optional.ofNullable(Strings.emptyToNull(individualMountPath.get()));
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public BooleanProperty usesReadOnlyMode() {
|
||||
return usesReadOnlyMode;
|
||||
}
|
||||
|
||||
@@ -246,10 +246,10 @@ public class UnlockController implements ViewController {
|
||||
useReadOnlyMode.setSelected(vaultSettings.usesReadOnlyMode().get());
|
||||
if (!settings.preferredVolumeImpl().get().equals(VolumeImpl.WEBDAV)) {
|
||||
useCustomMountPoint.setSelected(vaultSettings.usesIndividualMountPath().get());
|
||||
if (vaultSettings.individualMountPath().get() == null) {
|
||||
customMountPointLabel.textProperty().setValue(localization.getString("unlock.label.chooseMountPath"));
|
||||
if (Strings.isNullOrEmpty(vaultSettings.individualMountPath().get())) {
|
||||
customMountPointLabel.setText(localization.getString("unlock.label.chooseMountPath"));
|
||||
} else {
|
||||
customMountPointLabel.textProperty().setValue(displayablePath(vaultSettings.individualMountPath().getValueSafe()));
|
||||
customMountPointLabel.setText(displayablePath(vaultSettings.individualMountPath().getValueSafe()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.NotDirectoryException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
public class DokanyVolume implements Volume {
|
||||
@@ -49,7 +50,7 @@ public class DokanyVolume implements Volume {
|
||||
try {
|
||||
this.mount = mountFactory.mount(fs.getPath("/"), mountPath, mountName, FS_TYPE_NAME);
|
||||
} catch (MountFailedException e) {
|
||||
if (vaultSettings.usesIndividualMountPath().get()) {
|
||||
if (vaultSettings.getIndividualMountPath().isPresent()) {
|
||||
LOG.warn("Failed to mount vault into {}. Is this directory currently accessed by another process (e.g. Windows Explorer)?", mountPath);
|
||||
}
|
||||
throw new VolumeException("Unable to mount Filesystem", e);
|
||||
@@ -57,8 +58,9 @@ public class DokanyVolume implements Volume {
|
||||
}
|
||||
|
||||
private Path getMountPoint() throws VolumeException, IOException {
|
||||
if (vaultSettings.usesIndividualMountPath().get()) {
|
||||
Path customMountPoint = Paths.get(vaultSettings.individualMountPath().get());
|
||||
Optional<String> optionalCustomMountPoint = vaultSettings.getIndividualMountPath();
|
||||
if (optionalCustomMountPoint.isPresent()) {
|
||||
Path customMountPoint = Paths.get(optionalCustomMountPoint.get());
|
||||
checkProvidedMountPoint(customMountPoint);
|
||||
return customMountPoint;
|
||||
} else if (!Strings.isNullOrEmpty(vaultSettings.winDriveLetter().get())) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.NotDirectoryException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Optional;
|
||||
|
||||
public class FuseVolume implements Volume {
|
||||
|
||||
@@ -43,8 +44,9 @@ public class FuseVolume implements Volume {
|
||||
|
||||
@Override
|
||||
public void mount(CryptoFileSystem fs) throws IOException, FuseNotSupportedException, VolumeException {
|
||||
if (vaultSettings.usesIndividualMountPath().get()) {
|
||||
Path customMountPoint = Paths.get(vaultSettings.individualMountPath().get());
|
||||
Optional<String> optionalCustomMountPoint = vaultSettings.getIndividualMountPath();
|
||||
if (optionalCustomMountPoint.isPresent()) {
|
||||
Path customMountPoint = Paths.get(optionalCustomMountPoint.get());
|
||||
checkProvidedMountPoint(customMountPoint);
|
||||
this.mountPoint = customMountPoint;
|
||||
this.createdTemporaryMountPoint = false;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*******************************************************************************/
|
||||
package org.cryptomator.ui.model;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.Observable;
|
||||
import javafx.beans.binding.Binding;
|
||||
@@ -108,7 +109,7 @@ public class Vault {
|
||||
public synchronized void unlock(CharSequence passphrase) throws CryptoException, IOException, Volume.VolumeException {
|
||||
Platform.runLater(() -> state.set(State.PROCESSING));
|
||||
try {
|
||||
if (vaultSettings.usesIndividualMountPath().get() && vaultSettings.individualMountPath().get().isEmpty()) {
|
||||
if (vaultSettings.usesIndividualMountPath().get() && Strings.isNullOrEmpty(vaultSettings.individualMountPath().get())) {
|
||||
throw new NotDirectoryException("");
|
||||
}
|
||||
CryptoFileSystem fs = getCryptoFileSystem(passphrase);
|
||||
|
||||
Reference in New Issue
Block a user