Various fixes

This commit is contained in:
crschnick committed 2026-09-26 18:15:42 +00:00
1 parent 040654ae93
commit 1c19c4670f
24 files changed
+87 -18

No files matched your search

@@ -1,5 +1,6 @@
package io.xpipe.app.action;
import io.xpipe.app.core.AppCache;
import io.xpipe.app.core.AppRestart;
import io.xpipe.app.core.window.AppDialog;
import io.xpipe.app.ext.ProcModuleProvider;
@@ -26,12 +27,20 @@ public class XPipeUrlProvider implements LauncherUrlProvider {
}
if ("action".equals(a)) {
if (!checkPermission()) {
return null;
}
var query = uri.getQuery();
var action = ActionUrls.parse(query);
return action.orElse(null);
}
if ("sync".equals(a)) {
if (!checkPermission()) {
return null;
}
var repo = new String(Base64Helper.fromBase64UrlString(uri.getPath()), StandardCharsets.UTF_8);
var alreadySynced = AppPrefs.get().storageGitRemote().getValue() != null;
if (alreadySynced && !repo.equals(AppPrefs.get().storageGitRemote().getValue())) {
@@ -47,4 +56,17 @@ public class XPipeUrlProvider implements LauncherUrlProvider {
return null;
}
private boolean checkPermission() {
var cache = AppCache.getBoolean("externalUrlsPermitted", false);
if (cache) {
return true;
}
var r = AppDialog.confirm("externalUrl");
if (r) {
AppCache.update("externalUrlsPermitted", true);
}
return r;
}
}
@@ -84,7 +84,8 @@ public class AppInstance {
client.get()
.performRequest(DaemonOpenExchange.Request.builder()
.arguments(inputs)
.directory(AppProperties.get().getDataDir())
// Don't change dir when opening inputs
.directory(inputs.isEmpty() ? AppProperties.get().getDataDir() : null)
.build());
}
} catch (Exception ex) {
@@ -115,7 +116,6 @@ public class AppInstance {
client.get()
.performRequest(DaemonOpenExchange.Request.builder()
.arguments(List.of(e.getURI().toString()))
.directory(AppProperties.get().getDataDir())
.build());
} catch (Exception ex) {
ErrorEventFactory.fromThrowable(ex).expected().omit().handle();
@@ -97,7 +97,7 @@ public class AppOpenArguments {
try {
var path = Path.of(input);
if (Files.isRegularFile(path)) {
if (Files.isRegularFile(path) && path.isAbsolute() && path.getParent() != null) {
path = path.getParent();
}
@@ -5,14 +5,23 @@ import io.xpipe.app.process.CountDown;
import io.xpipe.app.process.SecretReference;
import io.xpipe.app.util.GlobalTimer;
import io.xpipe.app.util.SecretValue;
import lombok.Value;
import java.time.Duration;
import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;
public class SecretManager {
private static final Map<SecretReference, SecretValue> secrets = new HashMap<>();
@Value
private static class CachedValue {
SecretValue value;
Instant expiry;
}
private static final Map<SecretReference, CachedValue> secrets = new HashMap<>();
private static final Set<SecretQueryProgress> progress = new HashSet<>();
public static synchronized Optional<SecretQueryProgress> getProgress(UUID requestId, UUID storeId) {
@@ -119,7 +128,7 @@ public class SecretManager {
.collect(Collectors.toSet());
secrets.entrySet().removeAll(oldSecrets);
for (Map.Entry<SecretReference, SecretValue> e : oldSecrets) {
for (Map.Entry<SecretReference, CachedValue> e : oldSecrets) {
var newRef = new SecretReference(newId, e.getKey().getSubId());
secrets.put(newRef, e.getValue());
}
@@ -130,19 +139,16 @@ public class SecretManager {
}
public static synchronized void cache(SecretReference ref, SecretValue value, Duration duration) {
secrets.put(ref, value);
if (duration != null && duration.isPositive()) {
GlobalTimer.delay(
() -> {
synchronized (SecretManager.class) {
secrets.remove(ref);
}
},
duration);
}
secrets.put(ref, new CachedValue(value, duration != null && duration.isPositive() ? Instant.now().plus(duration) : null));
}
public static synchronized Optional<SecretValue> get(SecretReference ref) {
return Optional.ofNullable(secrets.get(ref));
var found = secrets.get(ref);
if (found.getExpiry() != null && found.getExpiry().isAfter(Instant.now())) {
secrets.remove(ref);
return Optional.empty();
}
return Optional.of(found.getValue());
}
}
@@ -78,8 +78,13 @@ public class ContextualFileReference {
public String serialize() {
var start = getDataDir();
var startString = start.toString();
var normalizedPath = FilePath.of(path).normalize().toUnix();
if (normalizedPath.startsWith(start) && !normalizedPath.equals(start)) {
var normalizedString = normalizedPath.toString();
// This guarantees a case-insensitive check
var startsWith = normalizedString.length() > startString.length() && normalizedString
.substring(0, startString.length()).equalsIgnoreCase(startString);
if (startsWith) {
return "<DATA>" + "/" + normalizedPath.relativize(start);
}
return path;