apply same error handling to "force lock" as well

This commit is contained in:
Sebastian Stenzel
2021-11-17 13:45:43 +01:00
parent 71a575e079
commit 1b43bf395f
2 changed files with 20 additions and 11 deletions

View File

@@ -16,7 +16,11 @@ public class UserInteractionLock<E extends Enum> {
private volatile E state;
public UserInteractionLock(E initialValue) {
state = initialValue;
this.state = initialValue;
}
public synchronized void reset(E value) {
this.state = value;
}
public void interacted(E result) {

View File

@@ -51,20 +51,25 @@ public class LockWorkflow extends Task<Void> {
@Override
protected Void call() throws Volume.VolumeException, InterruptedException, LockNotCompletedException {
try {
vault.lock(false);
} catch (Volume.VolumeException | LockNotCompletedException e) {
LOG.debug("Regular lock of {} failed.", vault.getDisplayName(), e);
var decision = askUserForAction();
switch (decision) {
case FORCE -> vault.lock(true);
case CANCEL -> cancel(false);
}
}
lock(false);
return null;
}
private void lock(boolean forced) throws InterruptedException {
try {
vault.lock(forced);
} catch (Volume.VolumeException | LockNotCompletedException e) {
LOG.info("Locking {} failed (forced: {}).", vault.getDisplayName(), forced, e);
var decision = askUserForAction();
switch (decision) {
case FORCE -> lock(true);
case CANCEL -> cancel(false);
}
}
}
private LockModule.ForceLockDecision askUserForAction() throws InterruptedException {
forceLockDecisionLock.reset(null);
// show forcedLock dialogue ...
Platform.runLater(() -> {
lockWindow.setScene(lockForcedScene.get());