mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-14 08:41:28 +00:00
Check vault path before preparing new vault in recovery flow and refactor chooseValidVaultDirectory() to return Path instead of File
This commit is contained in:
@@ -23,12 +23,11 @@ public final class VaultPreparator {
|
||||
|
||||
private VaultPreparator() {}
|
||||
|
||||
public static Vault prepareVault(File selectedDirectory, VaultComponent.Factory vaultComponentFactory, List<MountService> mountServices) {
|
||||
Path selectedPath = selectedDirectory.toPath();
|
||||
public static Vault prepareVault(Path selectedDirectory, VaultComponent.Factory vaultComponentFactory, List<MountService> mountServices) {
|
||||
VaultSettings vaultSettings = VaultSettings.withRandomId();
|
||||
vaultSettings.path.set(selectedPath);
|
||||
if (selectedPath.getFileName() != null) {
|
||||
vaultSettings.displayName.set(selectedPath.getFileName().toString());
|
||||
vaultSettings.path.set(selectedDirectory);
|
||||
if (selectedDirectory.getFileName() != null) {
|
||||
vaultSettings.displayName.set(selectedDirectory.getFileName().toString());
|
||||
} else {
|
||||
vaultSettings.displayName.set("defaultVaultName");
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ public class VaultListController implements FxController {
|
||||
VaultListManager.redetermineVaultState(newValue);
|
||||
}
|
||||
|
||||
private Optional<File> chooseValidVaultDirectory() {
|
||||
private Optional<Path> chooseValidVaultDirectory() {
|
||||
DirectoryChooser directoryChooser = new DirectoryChooser();
|
||||
File selectedDirectory;
|
||||
|
||||
@@ -243,7 +243,7 @@ public class VaultListController implements FxController {
|
||||
}
|
||||
} while (selectedDirectory == null);
|
||||
|
||||
return Optional.of(selectedDirectory);
|
||||
return Optional.of(selectedDirectory.toPath());
|
||||
}
|
||||
|
||||
@FXML
|
||||
@@ -258,14 +258,13 @@ public class VaultListController implements FxController {
|
||||
|
||||
@FXML
|
||||
public void didClickRecoverExistingVault() {
|
||||
Optional<File> selectedDirectory = chooseValidVaultDirectory();
|
||||
Optional<Path> selectedDirectory = chooseValidVaultDirectory();
|
||||
if (selectedDirectory.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Vault preparedVault = VaultPreparator.prepareVault(selectedDirectory.get(), vaultComponentFactory, mountServices);
|
||||
|
||||
Optional<Vault> matchingVaultListEntry = vaultListManager.get(preparedVault.getPath());
|
||||
Path path = selectedDirectory.get();
|
||||
Optional<Vault> matchingVaultListEntry = vaultListManager.get(path);
|
||||
if (matchingVaultListEntry.isPresent()) {
|
||||
dialogs.prepareRecoveryVaultAlreadyExists(mainWindow, matchingVaultListEntry.get().getDisplayName()) //
|
||||
.setOkAction(Stage::close) //
|
||||
@@ -273,6 +272,7 @@ public class VaultListController implements FxController {
|
||||
return;
|
||||
}
|
||||
|
||||
Vault preparedVault = VaultPreparator.prepareVault(path, vaultComponentFactory, mountServices);
|
||||
VaultListManager.redetermineVaultState(preparedVault);
|
||||
|
||||
switch (preparedVault.getState()) {
|
||||
|
||||
Reference in New Issue
Block a user