From c3fbddc671725038de12cb13f3fd6e42a0571392 Mon Sep 17 00:00:00 2001 From: JaniruTEC Date: Tue, 11 Aug 2020 02:50:33 +0200 Subject: [PATCH] Refactored PerVault, Vault and VaultSettings Made @`PerVault public Added import for VaultException to Vault Added convenience method to VaultSettings --- .../org/cryptomator/common/settings/VaultSettings.java | 8 ++++++++ .../main/java/org/cryptomator/common/vaults/PerVault.java | 2 +- .../main/java/org/cryptomator/common/vaults/Vault.java | 7 ++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/main/commons/src/main/java/org/cryptomator/common/settings/VaultSettings.java b/main/commons/src/main/java/org/cryptomator/common/settings/VaultSettings.java index 1a1dfe140..f702cff9f 100644 --- a/main/commons/src/main/java/org/cryptomator/common/settings/VaultSettings.java +++ b/main/commons/src/main/java/org/cryptomator/common/settings/VaultSettings.java @@ -120,6 +120,14 @@ public class VaultSettings { return winDriveLetter; } + public Optional getWinDriveLetter() { + String current = this.winDriveLetter.get(); + if (!Strings.isNullOrEmpty(current)) { + return Optional.of(current); + } + return Optional.empty(); + } + public BooleanProperty unlockAfterStartup() { return unlockAfterStartup; } diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/PerVault.java b/main/commons/src/main/java/org/cryptomator/common/vaults/PerVault.java index dab895b37..692349b61 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/PerVault.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/PerVault.java @@ -8,6 +8,6 @@ import java.lang.annotation.RetentionPolicy; @Scope @Documented @Retention(RetentionPolicy.RUNTIME) -@interface PerVault { +public @interface PerVault { } diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java b/main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java index d16e7815c..de41da4c1 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java @@ -17,6 +17,7 @@ import javafx.beans.property.ObjectProperty; import org.apache.commons.lang3.SystemUtils; import org.cryptomator.common.LazyInitializer; import org.cryptomator.common.settings.VaultSettings; +import org.cryptomator.common.vaults.Volume.VolumeException; import org.cryptomator.cryptofs.CryptoFileSystem; import org.cryptomator.cryptofs.CryptoFileSystemProperties; import org.cryptomator.cryptofs.CryptoFileSystemProperties.FileSystemFlags; @@ -120,7 +121,7 @@ public class Vault { return CryptoFileSystemProvider.newFileSystem(getPath(), fsProps); } - public synchronized void unlock(CharSequence passphrase) throws CryptoException, IOException, Volume.VolumeException { + public synchronized void unlock(CharSequence passphrase) throws CryptoException, IOException, VolumeException { if (vaultSettings.useCustomMountPath().get() && Strings.isNullOrEmpty(vaultSettings.customMountPath().get())) { throw new NotDirectoryException(""); } @@ -129,7 +130,7 @@ public class Vault { volume.mount(fs, getEffectiveMountFlags()); } - public synchronized void lock(boolean forced) throws Volume.VolumeException { + public synchronized void lock(boolean forced) throws VolumeException { if (forced && volume.supportsForcedUnmount()) { volume.unmountForced(); } else { @@ -145,7 +146,7 @@ public class Vault { } } - public void reveal() throws Volume.VolumeException { + public void reveal() throws VolumeException { volume.reveal(); }