From 00331d48572158cb0e1263d05ac98cbde69ba1a3 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Thu, 6 May 2021 13:51:30 +0200 Subject: [PATCH] check for vaultpath existence instead of catching (undocumented) exception --- .../common/vaults/VaultListManager.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/VaultListManager.java b/main/commons/src/main/java/org/cryptomator/common/vaults/VaultListManager.java index 6c36a6485..d5038630a 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/VaultListManager.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/VaultListManager.java @@ -21,6 +21,7 @@ import javax.inject.Singleton; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.util.Collection; @@ -126,15 +127,14 @@ public class VaultListManager { } private static VaultState.Value determineVaultState(Path pathToVault) throws IOException { - try { - return switch (CryptoFileSystemProvider.checkDirStructureForVault(pathToVault, VAULTCONFIG_FILENAME, MASTERKEY_FILENAME)) { - case VAULT -> VaultState.Value.LOCKED; - case UNRELATED -> VaultState.Value.MISSING; - case MAYBE_LEGACY -> Migrators.get().needsMigration(pathToVault, VAULTCONFIG_FILENAME, MASTERKEY_FILENAME) ? VaultState.Value.NEEDS_MIGRATION : VaultState.Value.MISSING; - }; - } catch (NoSuchFileException e) { + if (!Files.exists(pathToVault)) { return VaultState.Value.MISSING; } + return switch (CryptoFileSystemProvider.checkDirStructureForVault(pathToVault, VAULTCONFIG_FILENAME, MASTERKEY_FILENAME)) { + case VAULT -> VaultState.Value.LOCKED; + case UNRELATED -> VaultState.Value.MISSING; + case MAYBE_LEGACY -> Migrators.get().needsMigration(pathToVault, VAULTCONFIG_FILENAME, MASTERKEY_FILENAME) ? VaultState.Value.NEEDS_MIGRATION : VaultState.Value.MISSING; + }; } }