Sebastian Stenzel 3 anos atrás
pai
commit
d3cf199741

+ 3 - 5
src/main/java/org/cryptomator/ui/health/Check.java

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

+ 1 - 0
src/main/java/org/cryptomator/ui/health/HealthCheckComponent.java

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

+ 1 - 0
src/main/java/org/cryptomator/ui/health/HealthCheckModule.java

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

+ 2 - 5
src/main/java/org/cryptomator/ui/health/ReportWriter.java

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

+ 1 - 4
src/main/java/org/cryptomator/ui/health/Result.java

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

+ 5 - 0
src/main/java/org/cryptomator/ui/health/StartController.java

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

+ 1 - 0
src/main/java/org/cryptomator/ui/health/StartFailController.java

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

+ 1 - 0
src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java

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