mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-20 19:51:27 +00:00
fixing issue using an individual mountPath, renaming mountPath-Property, fixing gui issues with mountPath,
This commit is contained in:
@@ -36,7 +36,7 @@ public class VaultSettings {
|
||||
private final BooleanProperty unlockAfterStartup = new SimpleBooleanProperty(DEFAULT_UNLOCK_AFTER_STARTUP);
|
||||
private final BooleanProperty mountAfterUnlock = new SimpleBooleanProperty(DEFAULT_MOUNT_AFTER_UNLOCK);
|
||||
private final BooleanProperty revealAfterMount = new SimpleBooleanProperty(DEFAULT_REAVEAL_AFTER_MOUNT);
|
||||
private final StringProperty mountPath = new SimpleStringProperty();
|
||||
private final StringProperty individualMountPath = new SimpleStringProperty();
|
||||
|
||||
public VaultSettings(String id) {
|
||||
this.id = Objects.requireNonNull(id);
|
||||
@@ -45,7 +45,7 @@ public class VaultSettings {
|
||||
}
|
||||
|
||||
Observable[] observables() {
|
||||
return new Observable[]{path, mountName, winDriveLetter, unlockAfterStartup, mountAfterUnlock, revealAfterMount};
|
||||
return new Observable[]{path, mountName, winDriveLetter, unlockAfterStartup, mountAfterUnlock, revealAfterMount, individualMountPath};
|
||||
}
|
||||
|
||||
private void deriveMountNameFromPath(Path path) {
|
||||
@@ -124,8 +124,8 @@ public class VaultSettings {
|
||||
return revealAfterMount;
|
||||
}
|
||||
|
||||
public StringProperty mountPath() {
|
||||
return mountPath;
|
||||
public StringProperty individualMountPath() {
|
||||
return individualMountPath;
|
||||
}
|
||||
|
||||
/* Hashcode/Equals */
|
||||
|
||||
@@ -27,7 +27,9 @@ class VaultSettingsJsonAdapter {
|
||||
out.name("unlockAfterStartup").value(value.unlockAfterStartup().get());
|
||||
out.name("mountAfterUnlock").value(value.mountAfterUnlock().get());
|
||||
out.name("revealAfterMount").value(value.revealAfterMount().get());
|
||||
out.name("mountPath").value(value.mountPath().get());
|
||||
if(value.individualMountPath().isNotEmpty().get()){
|
||||
out.name("individualMountPath").value(value.individualMountPath().get());
|
||||
}
|
||||
out.endObject();
|
||||
}
|
||||
|
||||
@@ -35,7 +37,7 @@ class VaultSettingsJsonAdapter {
|
||||
String id = null;
|
||||
String path = null;
|
||||
String mountName = null;
|
||||
String mountPath = null;
|
||||
String individualMountPath = null;
|
||||
String winDriveLetter = null;
|
||||
boolean unlockAfterStartup = VaultSettings.DEFAULT_UNLOCK_AFTER_STARTUP;
|
||||
boolean mountAfterUnlock = VaultSettings.DEFAULT_MOUNT_AFTER_UNLOCK;
|
||||
@@ -66,8 +68,8 @@ class VaultSettingsJsonAdapter {
|
||||
case "revealAfterMount":
|
||||
revealAfterMount = in.nextBoolean();
|
||||
break;
|
||||
case "mountPath":
|
||||
mountPath = in.nextString();
|
||||
case "individualMountPath":
|
||||
individualMountPath = in.nextString();
|
||||
break;
|
||||
default:
|
||||
LOG.warn("Unsupported vault setting found in JSON: " + name);
|
||||
@@ -83,7 +85,7 @@ class VaultSettingsJsonAdapter {
|
||||
vaultSettings.unlockAfterStartup().set(unlockAfterStartup);
|
||||
vaultSettings.mountAfterUnlock().set(mountAfterUnlock);
|
||||
vaultSettings.revealAfterMount().set(revealAfterMount);
|
||||
vaultSettings.mountPath().set(mountPath);
|
||||
vaultSettings.individualMountPath().set(individualMountPath);
|
||||
return vaultSettings;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public class VaultSettingsJsonAdapterTest {
|
||||
Assert.assertEquals(Paths.get("/foo/bar"), vaultSettings.path().get());
|
||||
Assert.assertEquals("test", vaultSettings.mountName().get());
|
||||
Assert.assertEquals("X", vaultSettings.winDriveLetter().get());
|
||||
Assert.assertEquals("/home/test/crypto", vaultSettings.mountPath().get());
|
||||
Assert.assertEquals("/home/test/crypto", vaultSettings.individualMountPath().get());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<cryptomator.cryptofs.version>1.4.5</cryptomator.cryptofs.version>
|
||||
<cryptomator.webdav.version>1.0.3</cryptomator.webdav.version>
|
||||
<cryptomator.jni.version>1.0.2</cryptomator.jni.version>
|
||||
<cryptomator.fuse.version>0.1.2-SNAPSHOT</cryptomator.fuse.version>
|
||||
<cryptomator.fuse.version>0.1.0-SNAPSHOT</cryptomator.fuse.version>
|
||||
|
||||
<commons-io.version>2.5</commons-io.version>
|
||||
<commons-lang3.version>3.6</commons-lang3.version>
|
||||
|
||||
@@ -21,6 +21,8 @@ import javafx.beans.binding.Bindings;
|
||||
import javafx.scene.layout.HBox;
|
||||
import org.apache.commons.lang3.CharUtils;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.cryptomator.common.settings.NioAdapterImpl;
|
||||
import org.cryptomator.common.settings.Settings;
|
||||
import org.cryptomator.common.settings.VaultSettings;
|
||||
import org.cryptomator.cryptolib.api.InvalidPassphraseException;
|
||||
import org.cryptomator.cryptolib.api.UnsupportedVaultFormatException;
|
||||
@@ -75,17 +77,19 @@ public class UnlockController implements ViewController {
|
||||
private final WindowsDriveLetters driveLetters;
|
||||
private final ChangeListener<Character> driveLetterChangeListener = this::winDriveLetterDidChange;
|
||||
private final Optional<KeychainAccess> keychainAccess;
|
||||
private final Settings settings;
|
||||
private Vault vault;
|
||||
private Optional<UnlockListener> listener = Optional.empty();
|
||||
private Subscription vaultSubs = Subscription.EMPTY;
|
||||
|
||||
@Inject
|
||||
public UnlockController(Application app, Localization localization, AsyncTaskService asyncTaskService, WindowsDriveLetters driveLetters, Optional<KeychainAccess> keychainAccess) {
|
||||
public UnlockController(Application app, Localization localization, AsyncTaskService asyncTaskService, WindowsDriveLetters driveLetters, Optional<KeychainAccess> keychainAccess, Settings settings) {
|
||||
this.app = app;
|
||||
this.localization = localization;
|
||||
this.asyncTaskService = asyncTaskService;
|
||||
this.driveLetters = driveLetters;
|
||||
this.keychainAccess = keychainAccess;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@FXML
|
||||
@@ -155,29 +159,29 @@ public class UnlockController implements ViewController {
|
||||
mountName.textProperty().addListener(this::mountNameDidChange);
|
||||
savePassword.setDisable(!keychainAccess.isPresent());
|
||||
unlockAfterStartup.disableProperty().bind(savePassword.disabledProperty().or(savePassword.selectedProperty().not()));
|
||||
|
||||
mountPathBox.managedProperty().bind(mountPathLabel.visibleProperty());
|
||||
mountPath.managedProperty().bind(mountPathLabel.visibleProperty());
|
||||
changeMountPathButton.managedProperty().bind(mountPathLabel.visibleProperty());
|
||||
|
||||
if (SystemUtils.IS_OS_WINDOWS) {
|
||||
winDriveLetter.setConverter(new WinDriveLetterLabelConverter());
|
||||
mountPathBox.setMouseTransparent(true);
|
||||
mountPathLabel.setVisible(false);
|
||||
mountPathLabel.setManaged(false);
|
||||
mountPath.setVisible(false);
|
||||
mountPath.setManaged(false);
|
||||
changeMountPathButton.setVisible(false);
|
||||
changeMountPathButton.setManaged(false);
|
||||
//dirty cheat
|
||||
mountPathBox.setMouseTransparent(true);
|
||||
} else {
|
||||
winDriveLetterLabel.setVisible(false);
|
||||
winDriveLetterLabel.setManaged(false);
|
||||
winDriveLetter.setVisible(false);
|
||||
winDriveLetter.setManaged(false);
|
||||
if(settings.usedNioAdapterImpl().isEqualTo(NioAdapterImpl.WEBDAV.name()).get()){
|
||||
mountPathLabel.setVisible(false);
|
||||
mountPathLabel.setManaged(false);
|
||||
}
|
||||
}
|
||||
changeMountPathButton.disableProperty().bind(Bindings.createBooleanBinding(this::isDirVaild, mountPath.textProperty()).not());
|
||||
changeMountPathButton.visibleProperty().bind(
|
||||
Bindings.createBooleanBinding(
|
||||
() -> mountPathLabel.isVisible() && mountPath.textProperty().isEmpty().not().get(),
|
||||
mountPathLabel.visibleProperty(),
|
||||
mountPath.textProperty().isEmpty().not()
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -230,14 +234,19 @@ public class UnlockController implements ViewController {
|
||||
Arrays.fill(storedPw, ' ');
|
||||
}
|
||||
}
|
||||
VaultSettings settings = vault.getVaultSettings();
|
||||
unlockAfterStartup.setSelected(savePassword.isSelected() && settings.unlockAfterStartup().get());
|
||||
mountAfterUnlock.setSelected(settings.mountAfterUnlock().get());
|
||||
revealAfterMount.setSelected(settings.revealAfterMount().get());
|
||||
VaultSettings vaultSettings = vault.getVaultSettings();
|
||||
unlockAfterStartup.setSelected(savePassword.isSelected() && vaultSettings.unlockAfterStartup().get());
|
||||
mountAfterUnlock.setSelected(vaultSettings.mountAfterUnlock().get());
|
||||
revealAfterMount.setSelected(vaultSettings.revealAfterMount().get());
|
||||
|
||||
vaultSubs = vaultSubs.and(EasyBind.subscribe(unlockAfterStartup.selectedProperty(), settings.unlockAfterStartup()::set));
|
||||
vaultSubs = vaultSubs.and(EasyBind.subscribe(mountAfterUnlock.selectedProperty(), settings.mountAfterUnlock()::set));
|
||||
vaultSubs = vaultSubs.and(EasyBind.subscribe(revealAfterMount.selectedProperty(), settings.revealAfterMount()::set));
|
||||
vaultSubs = vaultSubs.and(EasyBind.subscribe(unlockAfterStartup.selectedProperty(), vaultSettings.unlockAfterStartup()::set));
|
||||
vaultSubs = vaultSubs.and(EasyBind.subscribe(mountAfterUnlock.selectedProperty(), vaultSettings.mountAfterUnlock()::set));
|
||||
vaultSubs = vaultSubs.and(EasyBind.subscribe(revealAfterMount.selectedProperty(), vaultSettings.revealAfterMount()::set));
|
||||
|
||||
changeMountPathButton.visibleProperty().bind(
|
||||
vaultSettings.individualMountPath().isNotEqualTo(mountPath.textProperty())
|
||||
);
|
||||
mountPath.textProperty().setValue(vaultSettings.individualMountPath().getValueSafe());
|
||||
|
||||
}
|
||||
|
||||
@@ -276,8 +285,7 @@ public class UnlockController implements ViewController {
|
||||
Path p = Paths.get(mountPath.textProperty().get());
|
||||
return Files.isDirectory(p) && Files.isReadable(p) && Files.isWritable(p) && Files.isExecutable(p);
|
||||
} else {
|
||||
//default path will be taken
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
} catch (InvalidPathException e) {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class FuseVolume implements Volume {
|
||||
@Override
|
||||
public void prepare(CryptoFileSystem fs) {
|
||||
this.cfs = fs;
|
||||
if (!(vaultSettings.mountPath().isNotNull().get() || SystemUtils.IS_OS_WINDOWS)) {
|
||||
if (!(vaultSettings.individualMountPath().isNotNull().get() || SystemUtils.IS_OS_WINDOWS)) {
|
||||
fuseMnt.useExtraMountDir();
|
||||
}
|
||||
}
|
||||
@@ -64,17 +64,12 @@ public class FuseVolume implements Volume {
|
||||
// auto assign drive letter selected
|
||||
return windowsDriveLetters.getAvailableDriveLetters().iterator().next() + ":\\";
|
||||
}
|
||||
} else {
|
||||
if (vaultSettings.mountPath().isNotNull().get()) {
|
||||
} else if (vaultSettings.individualMountPath().isNotNull().get()) {
|
||||
//specific path given
|
||||
vaultSettings.mountPath().getValue();
|
||||
} else {
|
||||
//choose default path
|
||||
return SystemUtils.IS_OS_MAC ? DEFAULT_MOUNTROOTPATH_MAC : DEFAULT_MOUNTROOTPATH_LINUX;
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
return vaultSettings.individualMountPath().getValue();
|
||||
}
|
||||
//choose default path
|
||||
return SystemUtils.IS_OS_MAC ? DEFAULT_MOUNTROOTPATH_MAC : DEFAULT_MOUNTROOTPATH_LINUX;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -258,11 +258,11 @@ public class Vault {
|
||||
}
|
||||
|
||||
public StringProperty getMountPathProperty() {
|
||||
return vaultSettings.mountPath();
|
||||
return vaultSettings.individualMountPath();
|
||||
}
|
||||
|
||||
public void setMountPath(String mountPath) {
|
||||
vaultSettings.mountPath().set(mountPath);
|
||||
vaultSettings.individualMountPath().set(mountPath);
|
||||
}
|
||||
|
||||
public void setMountName(String mountName) throws IllegalArgumentException {
|
||||
|
||||
Reference in New Issue
Block a user