mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-07-20 06:52:36 +00:00
Merge branch 'develop' into feature/hub
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -35,7 +35,13 @@ public class LockForcedController implements FxController {
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void confirmForcedLock() {
|
||||
public void retry() {
|
||||
forceLockDecisionLock.interacted(LockModule.ForceLockDecision.RETRY);
|
||||
window.close();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void force() {
|
||||
forceLockDecisionLock.interacted(LockModule.ForceLockDecision.FORCE);
|
||||
window.close();
|
||||
}
|
||||
@@ -54,4 +60,8 @@ public class LockForcedController implements FxController {
|
||||
return vault.getDisplayName();
|
||||
}
|
||||
|
||||
public boolean isForceSupported() {
|
||||
return vault.supportsForcedUnmount();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ abstract class LockModule {
|
||||
|
||||
enum ForceLockDecision {
|
||||
CANCEL,
|
||||
RETRY,
|
||||
FORCE;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,20 +51,26 @@ 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 RETRY -> lock(false);
|
||||
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());
|
||||
|
||||
@@ -34,10 +34,10 @@ public class SupporterCertificateController implements FxController {
|
||||
public void initialize() {
|
||||
supporterCertificateField.setText(licenseHolder.getLicenseKey().orElse(null));
|
||||
supporterCertificateField.textProperty().addListener(this::registrationKeyChanged);
|
||||
supporterCertificateField.setTextFormatter(new TextFormatter<>(this::checkVaultNameLength));
|
||||
supporterCertificateField.setTextFormatter(new TextFormatter<>(this::removeWhitespaces));
|
||||
}
|
||||
|
||||
private TextFormatter.Change checkVaultNameLength(TextFormatter.Change change) {
|
||||
private TextFormatter.Change removeWhitespaces(TextFormatter.Change change) {
|
||||
if (change.isContentChange()) {
|
||||
var strippedText = CharMatcher.whitespace().removeFrom(change.getText());
|
||||
change.setText(strippedText);
|
||||
|
||||
@@ -47,7 +47,7 @@ public class GeneralVaultOptionsController implements FxController {
|
||||
public void initialize() {
|
||||
vaultName.textProperty().set(vault.getVaultSettings().displayName().get());
|
||||
vaultName.focusedProperty().addListener(this::trimVaultNameOnFocusLoss);
|
||||
vaultName.setTextFormatter(new TextFormatter<>(this::removeWhitespaces));
|
||||
vaultName.setTextFormatter(new TextFormatter<>(this::checkVaultNameLength));
|
||||
unlockOnStartupCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().unlockAfterStartup());
|
||||
actionAfterUnlockChoiceBox.getItems().addAll(WhenUnlocked.values());
|
||||
actionAfterUnlockChoiceBox.valueProperty().bindBidirectional(vault.getVaultSettings().actionAfterUnlock());
|
||||
@@ -63,7 +63,7 @@ public class GeneralVaultOptionsController implements FxController {
|
||||
}
|
||||
}
|
||||
|
||||
private TextFormatter.Change removeWhitespaces(TextFormatter.Change change) {
|
||||
private TextFormatter.Change checkVaultNameLength(TextFormatter.Change change) {
|
||||
if (change.isContentChange() && change.getControlNewText().length() > VAULTNAME_TRUNCATE_THRESHOLD) {
|
||||
return null; // reject any change that would lead to a text exceeding threshold
|
||||
} else {
|
||||
|
||||
@@ -33,11 +33,11 @@
|
||||
</HBox>
|
||||
|
||||
<VBox alignment="BOTTOM_CENTER" VBox.vgrow="ALWAYS">
|
||||
<ButtonBar buttonMinWidth="120" buttonOrder="+CI">
|
||||
<ButtonBar buttonMinWidth="100" buttonOrder="+CIU">
|
||||
<buttons>
|
||||
<Button text="%generic.button.cancel" ButtonBar.buttonData="CANCEL_CLOSE" defaultButton="true" cancelButton="true" onAction="#cancel"/>
|
||||
<!-- TODO: third button with retry? -->
|
||||
<Button text="%lock.forced.confirmBtn" ButtonBar.buttonData="FINISH" onAction="#confirmForcedLock"/>
|
||||
<Button text="%lock.forced.retryBtn" ButtonBar.buttonData="FINISH" onAction="#retry"/>
|
||||
<Button text="%lock.forced.forceBtn" ButtonBar.buttonData="OTHER" onAction="#force" disable="${!controller.forceSupported}"/>
|
||||
</buttons>
|
||||
</ButtonBar>
|
||||
</VBox>
|
||||
|
||||
@@ -118,9 +118,10 @@ unlock.error.invalidMountPoint.existing=Mount point "%s" already exists or paren
|
||||
|
||||
# Lock
|
||||
## Force
|
||||
lock.forced.heading=Graceful lock failed
|
||||
lock.forced.heading=Lock failed
|
||||
lock.forced.message=Locking "%s" was blocked by pending operations or open files. You can force lock this vault, however interrupting I/O may result in the loss of unsaved data.
|
||||
lock.forced.confirmBtn=Force Lock
|
||||
lock.forced.retryBtn=Retry
|
||||
lock.forced.forceBtn=Force Lock
|
||||
## Failure
|
||||
lock.fail.heading=Locking vault failed.
|
||||
lock.fail.message=Vault "%s" could not be locked. Ensure unsaved work is saved elsewhere and important Read/Write operations are finished. In order to close the vault, kill the Cryptomator process.
|
||||
|
||||
Reference in New Issue
Block a user