This commit is contained in:
Armin Schrenk
2024-08-16 12:59:38 +02:00
committed by GitHub
parent d448c42f87
commit 77b908199e

View File

@@ -1,6 +1,8 @@
package org.cryptomator.ui.addvaultwizard;
import dagger.Lazy;
import org.apache.commons.lang3.SystemUtils;
import org.cryptomator.common.settings.VaultSettings;
import org.cryptomator.common.vaults.Vault;
import org.cryptomator.common.vaults.VaultListManager;
import org.cryptomator.cryptofs.CryptoFileSystemProperties;
@@ -10,6 +12,7 @@ import org.cryptomator.cryptolib.api.CryptorProvider;
import org.cryptomator.cryptolib.api.Masterkey;
import org.cryptomator.cryptolib.api.MasterkeyLoader;
import org.cryptomator.cryptolib.common.MasterkeyFileAccess;
import org.cryptomator.integrations.mount.MountService;
import org.cryptomator.ui.changepassword.NewPasswordController;
import org.cryptomator.ui.common.FxController;
import org.cryptomator.ui.common.FxmlFile;
@@ -43,6 +46,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.security.SecureRandom;
import java.util.List;
import java.util.ResourceBundle;
import java.util.concurrent.ExecutorService;
@@ -61,6 +65,7 @@ public class CreateNewVaultPasswordController implements FxController {
private final Lazy<Scene> successScene;
private final FxApplicationWindows appWindows;
private final ExecutorService executor;
private final List<MountService> mountProviders;
private final RecoveryKeyFactory recoveryKeyFactory;
private final StringProperty vaultNameProperty;
private final ObjectProperty<Path> vaultPathProperty;
@@ -89,7 +94,7 @@ public class CreateNewVaultPasswordController implements FxController {
@FxmlScene(FxmlFile.ADDVAULT_SUCCESS) Lazy<Scene> successScene, //
FxApplicationWindows appWindows, //
ExecutorService executor, //
RecoveryKeyFactory recoveryKeyFactory, //
List<MountService> mountProviders, RecoveryKeyFactory recoveryKeyFactory, //
@Named("vaultName") StringProperty vaultName, //
ObjectProperty<Path> vaultPath, //
@AddVaultWizardWindow ObjectProperty<Vault> vault, //
@@ -106,6 +111,7 @@ public class CreateNewVaultPasswordController implements FxController {
this.successScene = successScene;
this.appWindows = appWindows;
this.executor = executor;
this.mountProviders = mountProviders;
this.recoveryKeyFactory = recoveryKeyFactory;
this.vaultNameProperty = vaultName;
this.vaultPathProperty = vaultPath;
@@ -223,12 +229,25 @@ public class CreateNewVaultPasswordController implements FxController {
private void creationSucceeded(Path pathToVault) {
try {
Vault newVault = vaultListManager.add(pathToVault);
postProcessVaultSettings(newVault.getVaultSettings());
vaultProperty.set(newVault);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
//due to https://github.com/cryptomator/cryptomator/issues/2880#issuecomment-1680313498
@Deprecated()
private void postProcessVaultSettings(VaultSettings vaultSettings) {
var nameOfWinfspLocalMounter = "org.cryptomator.frontend.fuse.mount.WinFspMountProvider";
if (SystemUtils.IS_OS_WINDOWS //
&& vaultSettings.path.get().toString().contains("Dropbox") //
&& mountProviders.stream().anyMatch(s -> s.getClass().getName().equals(nameOfWinfspLocalMounter))) {
vaultSettings.mountService.setValue(nameOfWinfspLocalMounter);
}
}
/* Getter/Setter */
public String getVaultName() {