This commit is contained in:
Sebastian Stenzel
2021-07-21 11:58:57 +02:00
parent 9f7c69388c
commit d3cf199741
8 changed files with 15 additions and 14 deletions

View File

@@ -14,8 +14,6 @@ import javafx.collections.ObservableList;
public class Check {
private static final String LOCALIZE_PREFIX = "health.";
private final HealthCheck check;
private final BooleanProperty chosenForExecution = new SimpleBooleanProperty(false);
@@ -45,7 +43,7 @@ public class Check {
return chosenForExecution.get();
}
ObjectProperty stateProperty() {
ObjectProperty<CheckState> stateProperty() {
return state;
}
@@ -57,7 +55,7 @@ public class Check {
state.set(newState);
}
ObjectProperty errorProperty() {
ObjectProperty<Throwable> errorProperty() {
return error;
}
@@ -69,7 +67,7 @@ public class Check {
error.set(t);
}
ObjectProperty highestResultSeverityProperty() {
ObjectProperty<DiagnosticResult.Severity> highestResultSeverityProperty() {
return highestResultSeverity;
}

View File

@@ -29,6 +29,7 @@ public interface HealthCheckComponent {
default Stage showHealthCheckWindow() {
Stage stage = window();
// TODO reevaluate config loading, as soon as we have the new generic error screen
var unverifiedConf = loadConfig();
if (unverifiedConf.config() != null) {
stage.setScene(startScene().get());

View File

@@ -37,6 +37,7 @@ import java.util.concurrent.atomic.AtomicReference;
@Module(subcomponents = {KeyLoadingComponent.class})
abstract class HealthCheckModule {
// TODO reevaluate config loading, as soon as we have the new generic error screen
@Provides
@HealthCheckScoped
static HealthCheckComponent.LoadUnverifiedConfigResult provideLoadConfigResult(@HealthCheckWindow Vault vault) {

View File

@@ -1,11 +1,9 @@
package org.cryptomator.ui.health;
import org.apache.commons.lang3.exception.ExceptionUtils;
import com.google.common.base.Throwables;
import org.cryptomator.common.Environment;
import org.cryptomator.common.vaults.Vault;
import org.cryptomator.cryptofs.VaultConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javafx.application.Application;
@@ -27,7 +25,6 @@ import java.util.stream.Collectors;
@HealthCheckScoped
public class ReportWriter {
private static final Logger LOG = LoggerFactory.getLogger(ReportWriter.class);
private static final String REPORT_HEADER = """
*******************************************
* Cryptomator Vault Health Report *
@@ -85,7 +82,7 @@ public class ReportWriter {
private String prepareFailureMsg(Check check) {
if (check.getError() != null) {
return ExceptionUtils.getStackTrace(check.getError()) //
return Throwables.getStackTraceAsString(check.getError()) //
.lines() //
.map(line -> "\t\t" + line + "\n") //
.collect(Collectors.joining());

View File

@@ -17,10 +17,7 @@ record Result(DiagnosticResult diagnosis, ObjectProperty<FixState> fixState) {
}
public static Result create(DiagnosticResult diagnosis) {
FixState initialState = switch (diagnosis.getSeverity()) {
case WARN -> FixState.FIXABLE;
default -> FixState.NOT_FIXABLE;
};
FixState initialState = diagnosis.getSeverity() == DiagnosticResult.Severity.WARN ? FixState.FIXABLE : FixState.NOT_FIXABLE;
return new Result(diagnosis, new SimpleObjectProperty<>(initialState));
}

View File

@@ -74,6 +74,8 @@ public class StartController implements FxController {
assert !Platform.isFxApplicationThread();
assert unverifiedVaultConfig.get() != null;
var unverifiedCfg = unverifiedVaultConfig.get();
// TODO: dedup keyloading w/ UnlockWorkflow.attemptUnlock()
boolean success = false;
try (var masterkey = keyLoadingStrategy.loadKey(unverifiedCfg.getKeyId())) {
var verifiedCfg = unverifiedCfg.verify(masterkey.getEncoded(), unverifiedCfg.allegedVaultVersion());
vaultConfigRef.set(verifiedCfg);
@@ -81,6 +83,7 @@ public class StartController implements FxController {
if (old != null) {
old.destroy();
}
success = true;
} catch (MasterkeyLoadingFailedException e) {
if (keyLoadingStrategy.recoverFromException(e)) {
// retry
@@ -90,6 +93,8 @@ public class StartController implements FxController {
}
} catch (VaultConfigLoadException e) {
throw new LoadingFailedException(e);
} finally {
keyLoadingStrategy.cleanup(success);
}
}

View File

@@ -16,6 +16,7 @@ import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
// TODO reevaluate config loading, as soon as we have the new generic error screen
@HealthCheckScoped
public class StartFailController implements FxController {

View File

@@ -68,6 +68,7 @@ public class UnlockWorkflow extends Task<Boolean> {
}
private void attemptUnlock() throws IOException, VolumeException, InvalidMountPointException, CryptoException {
// TODO: dedup keyloading w/ StartController.loadKey()
boolean success = false;
try {
vault.unlock(keyLoadingStrategy);