Преглед изворни кода

Refactored PerVault, Vault and VaultSettings

Made @`PerVault public
Added import for VaultException to Vault
Added convenience method to VaultSettings
JaniruTEC пре 5 година
родитељ
комит
c3fbddc671

+ 8 - 0
main/commons/src/main/java/org/cryptomator/common/settings/VaultSettings.java

@@ -120,6 +120,14 @@ public class VaultSettings {
 		return winDriveLetter;
 	}
 
+	public Optional<String> getWinDriveLetter() {
+		String current = this.winDriveLetter.get();
+		if (!Strings.isNullOrEmpty(current)) {
+			return Optional.of(current);
+		}
+		return Optional.empty();
+	}
+
 	public BooleanProperty unlockAfterStartup() {
 		return unlockAfterStartup;
 	}

+ 1 - 1
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 {
 
 }

+ 4 - 3
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();
 	}