mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-10-07 23:51:28 +00:00
Rework pause delay
This commit is contained in:
1 file changed
+19
-18
@@ -119,7 +119,7 @@ public class KeePassXcPasswordManager implements PasswordManager {
|
||||
p);
|
||||
}
|
||||
|
||||
private static synchronized KeePassXcAssociationKey associate() throws Exception {
|
||||
private static KeePassXcAssociationKey associate() throws Exception {
|
||||
var found = findKeePassProxy();
|
||||
if (found.isEmpty()) {
|
||||
throw ErrorEventFactory.expected(new UnsupportedOperationException("No KeePassXC installation was found"));
|
||||
@@ -137,14 +137,14 @@ public class KeePassXcPasswordManager implements PasswordManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void reset() {
|
||||
public static void reset() {
|
||||
if (client != null) {
|
||||
client.disconnect();
|
||||
client = null;
|
||||
}
|
||||
}
|
||||
|
||||
private KeePassXcProxyClient getOrCreateClient() throws Exception {
|
||||
private synchronized KeePassXcProxyClient getOrCreateClient() throws Exception {
|
||||
if (client == null) {
|
||||
var found = findKeePassProxy();
|
||||
if (found.isEmpty()) {
|
||||
@@ -269,21 +269,22 @@ public class KeePassXcPasswordManager implements PasswordManager {
|
||||
|
||||
@Override
|
||||
public Result query(String key) {
|
||||
synchronized (KeePassXcPasswordManager.class) {
|
||||
try {
|
||||
var hasScheme = Pattern.compile("^\\w+://").matcher(key).find();
|
||||
var fixedKey = hasScheme ? key : "https://" + key;
|
||||
var isPrefs = this == AppPrefs.get().passwordManager().getValue();
|
||||
var client = getOrCreateClient();
|
||||
// The prefs value might be updated during the client creation
|
||||
var effectiveKeys =
|
||||
isPrefs ? ((KeePassXcPasswordManager) AppPrefs.get().passwordManager().getValue()).getAssociationKeys() : associationKeys;
|
||||
var credentials = client.getCredentials(effectiveKeys, fixedKey);
|
||||
return Result.of(credentials, null);
|
||||
} catch (Exception e) {
|
||||
ErrorEventFactory.fromThrowable(e).handle();
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
var hasScheme = Pattern.compile("^\\w+://").matcher(key).find();
|
||||
var fixedKey = hasScheme ? key : "https://" + key;
|
||||
var isPrefs = this == AppPrefs.get().passwordManager().getValue();
|
||||
var client = getOrCreateClient();
|
||||
// The prefs value might be updated during the client creation
|
||||
var effectiveKeys = isPrefs
|
||||
? ((KeePassXcPasswordManager)
|
||||
AppPrefs.get().passwordManager().getValue())
|
||||
.getAssociationKeys()
|
||||
: associationKeys;
|
||||
var credentials = client.getCredentials(effectiveKeys, fixedKey);
|
||||
return Result.of(credentials, null);
|
||||
} catch (Exception e) {
|
||||
ErrorEventFactory.fromThrowable(e).handle();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user