Kaynağa Gözat

Change logic on how the config wrapper is injected

Armin Schrenk 3 yıl önce
ebeveyn
işleme
a0fd6618a7

+ 4 - 0
src/main/java/org/cryptomator/common/vaults/VaultComponent.java

@@ -10,6 +10,7 @@ import dagger.Subcomponent;
 import org.cryptomator.common.Nullable;
 import org.cryptomator.common.mountpoint.MountPointChooserModule;
 import org.cryptomator.common.settings.VaultSettings;
+import org.cryptomator.cryptofs.VaultConfig;
 
 import javax.inject.Named;
 
@@ -25,6 +26,9 @@ public interface VaultComponent {
 		@BindsInstance
 		Builder vaultSettings(VaultSettings vaultSettings);
 
+		@BindsInstance
+		Builder vaultConfigWrapper(VaultConfigWrapper rapper);
+
 		@BindsInstance
 		Builder initialVaultState(VaultState.Value vaultState);
 

+ 0 - 2
src/main/java/org/cryptomator/common/vaults/VaultConfigWrapper.java

@@ -17,13 +17,11 @@ import java.util.Objects;
 /**
  * Wrapper for lazy loading and on-demand reloading of the vault configuration.
  */
-@PerVault
 public class VaultConfigWrapper {
 
 	private final VaultSettings settings;
 	private final ObjectProperty<VaultConfig.UnverifiedVaultConfig> config;
 
-	@Inject
 	VaultConfigWrapper(VaultSettings settings) {
 		this.settings = settings;
 		this.config = new SimpleObjectProperty<>();

+ 3 - 2
src/main/java/org/cryptomator/common/vaults/VaultListManager.java

@@ -98,8 +98,9 @@ public class VaultListManager {
 		try {
 			VaultState.Value vaultState = determineVaultState(vaultSettings.path().get());
 			if (vaultState == LOCKED) {
-				//TODO: maybe already set it in the vault Wrapper ?
-				VaultConfig.UnverifiedVaultConfig config = VaultConfigWrapper.readConfigFromStorage(vaultSettings.path().get());
+				VaultConfigWrapper wrapper = new VaultConfigWrapper(vaultSettings);
+				compBuilder.vaultConfigWrapper(wrapper); //first set the wrapper in the builder, THEN try to load config
+				wrapper.reloadConfig();
 			}
 			compBuilder.initialVaultState(vaultState);
 		} catch (IOException e) {