Change logic on how the config wrapper is injected

This commit is contained in:
Armin Schrenk
2021-09-03 12:25:26 +02:00
parent 09a2f76e15
commit a0fd6618a7
3 changed files with 7 additions and 4 deletions

View File

@@ -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);

View File

@@ -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<>();

View File

@@ -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) {