瀏覽代碼

Fix not showing dir picker dialog when path does not exist

Armin Schrenk 3 年之前
父節點
當前提交
9e594ea127
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      src/main/java/org/cryptomator/ui/vaultoptions/MountOptionsController.java

+ 6 - 2
src/main/java/org/cryptomator/ui/vaultoptions/MountOptionsController.java

@@ -24,6 +24,7 @@ import javafx.stage.DirectoryChooser;
 import javafx.stage.Stage;
 import javafx.util.StringConverter;
 import java.io.File;
+import java.nio.file.Files;
 import java.nio.file.InvalidPathException;
 import java.nio.file.Path;
 import java.util.ResourceBundle;
@@ -122,8 +123,11 @@ public class MountOptionsController implements FxController {
 		DirectoryChooser directoryChooser = new DirectoryChooser();
 		directoryChooser.setTitle(resourceBundle.getString("vaultOptions.mount.mountPoint.directoryPickerTitle"));
 		try {
-			var initialDir = vault.getVaultSettings().getCustomMountPath().orElse(System.getProperty("user.home"));
-			directoryChooser.setInitialDirectory(Path.of(initialDir).toFile());
+			var initialDir = Path.of(vault.getVaultSettings().getCustomMountPath().orElse(System.getProperty("user.home")));
+
+			if(Files.exists(initialDir)) {
+				directoryChooser.setInitialDirectory(initialDir.toFile());
+			}
 		} catch (InvalidPathException e) {
 			// no-op
 		}