adjusted to new async health check api

This commit is contained in:
Sebastian Stenzel
2021-04-09 16:04:52 +02:00
parent 13db1aa9b9
commit 69186b916c
2 changed files with 13 additions and 11 deletions

View File

@@ -25,7 +25,7 @@
<project.jdk.version>16</project.jdk.version>
<!-- cryptomator dependencies -->
<cryptomator.cryptofs.version>2.1.0-beta1</cryptomator.cryptofs.version>
<cryptomator.cryptofs.version>2.1.0-beta2</cryptomator.cryptofs.version>
<cryptomator.integrations.version>1.0.0-beta2</cryptomator.integrations.version>
<cryptomator.integrations.win.version>1.0.0-beta2</cryptomator.integrations.win.version>
<cryptomator.integrations.mac.version>1.0.0-beta2</cryptomator.integrations.mac.version>

View File

@@ -16,6 +16,7 @@ import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicReference;
@HealthCheckScoped
@@ -28,28 +29,29 @@ public class CheckController implements FxController {
private final Masterkey masterkey;
private final VaultConfig vaultConfig;
private final SecureRandom csprng;
private final ExecutorService executor;
@Inject
public CheckController(@HealthCheckWindow Vault vault, @HealthCheckWindow Stage window, AtomicReference<Masterkey> masterkeyRef, AtomicReference<VaultConfig> vaultConfigRef, SecureRandom csprng) {
public CheckController(@HealthCheckWindow Vault vault, @HealthCheckWindow Stage window, AtomicReference<Masterkey> masterkeyRef, AtomicReference<VaultConfig> vaultConfigRef, SecureRandom csprng, ExecutorService executor) {
this.vault = vault;
this.window = window;
this.masterkey = Objects.requireNonNull(masterkeyRef.get());
this.vaultConfig = Objects.requireNonNull(vaultConfigRef.get());
this.csprng = csprng;
this.executor = executor;
}
@FXML
public void runCheck() {
// TODO run in background task...
try (var cryptor = vaultConfig.getCipherCombo().getCryptorProvider(csprng).withKey(masterkey)) {
List<DiagnosticResult> results = new ArrayList<>();
HealthCheck.allChecks().forEach(c -> {
LOG.info("Running check {}...", c.identifier());
results.addAll(c.check(vault.getPath(), vaultConfig, masterkey, cryptor));
});
results.forEach(r -> {
LOG.info("Result: {}", r);
});
HealthCheck.allChecks().stream()
.peek(check -> {
LOG.info("Running check: {}", check.identifier());
})
.flatMap(check -> check.check(vault.getPath(), vaultConfig, masterkey, cryptor, executor))
.forEach(result -> {
LOG.info("Result: {}", result);
});
}
}