From 79841ee5945e2bf0a523fb2dddb0456b07a83737 Mon Sep 17 00:00:00 2001 From: crschnick Date: Fri, 2 Oct 2026 09:22:15 +0000 Subject: [PATCH] Fix secret cache --- .../xpipe/app/hub/creation/StoreCreationModel.java | 12 +++++++----- .../main/java/io/xpipe/app/secret/SecretManager.java | 4 ++++ .../main/java/io/xpipe/app/secret/SecretQuery.java | 4 ++-- .../main/java/io/xpipe/app/storage/DataStorage.java | 2 ++ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/hub/creation/StoreCreationModel.java b/app/src/main/java/io/xpipe/app/hub/creation/StoreCreationModel.java index eebc96fd5..c5a8cb210 100644 --- a/app/src/main/java/io/xpipe/app/hub/creation/StoreCreationModel.java +++ b/app/src/main/java/io/xpipe/app/hub/creation/StoreCreationModel.java @@ -49,7 +49,8 @@ public class StoreCreationModel { boolean staticDisplay; StoreCreationConsumer consumer; ObservableBooleanValue syncable; - UUID uuid; + UUID newEntryUuid; + UUID cacheTargetUuid; String defaultName; public StoreCreationModel( @@ -74,9 +75,10 @@ public class StoreCreationModel { : null; this.staticDisplay = staticDisplay; this.consumer = consumer; - this.uuid = existingEntry != null && !DataStorage.get().getEffectiveReadOnlyState(existingEntry) + this.newEntryUuid = UUID.randomUUID(); + this.cacheTargetUuid = existingEntry != null && !DataStorage.get().getEffectiveReadOnlyState(existingEntry) ? existingEntry.getUuid() - : UUID.randomUUID(); + : newEntryUuid; this.provider.addListener((c, o, n) -> { store.unbind(); @@ -107,12 +109,12 @@ public class StoreCreationModel { } var initial = DataStoreEntry.createNew( - uuid, DataStorage.get().getSelectedCategory().getUuid(), effectiveName, store.getValue()); + newEntryUuid, DataStorage.get().getSelectedCategory().getUuid(), effectiveName, store.getValue()); var entryRef = existingEntry != null ? existingEntry : DataStorage.get().getDefaultDisplayParent(initial).orElse(initial); var targetCategory = getTargetCategory(entryRef.getCategoryUuid()); - var e = DataStoreEntry.createNew(uuid, targetCategory.getUuid(), effectiveName, store.getValue()); + var e = DataStoreEntry.createNew(newEntryUuid, targetCategory.getUuid(), effectiveName, store.getValue()); if (!store.getValue().equals(e.getStore())) { ErrorEventFactory.fromMessage("Store serialization mismatch") diff --git a/app/src/main/java/io/xpipe/app/secret/SecretManager.java b/app/src/main/java/io/xpipe/app/secret/SecretManager.java index a345d7c88..dd9b6e069 100644 --- a/app/src/main/java/io/xpipe/app/secret/SecretManager.java +++ b/app/src/main/java/io/xpipe/app/secret/SecretManager.java @@ -123,6 +123,10 @@ public class SecretManager { } public static synchronized void moveReferences(UUID oldId, UUID newId) { + if (oldId.equals(newId)) { + return; + } + var oldSecrets = secrets.entrySet().stream() .filter(e -> e.getKey().getSecretId().equals(oldId)) .collect(Collectors.toSet()); diff --git a/app/src/main/java/io/xpipe/app/secret/SecretQuery.java b/app/src/main/java/io/xpipe/app/secret/SecretQuery.java index 72a053573..53520e84c 100644 --- a/app/src/main/java/io/xpipe/app/secret/SecretQuery.java +++ b/app/src/main/java/io/xpipe/app/secret/SecretQuery.java @@ -56,12 +56,12 @@ public interface SecretQuery { @Override public Duration cacheDuration() { - return null; + return original.cacheDuration(); } @Override public boolean retryOnFail() { - return true; + return original.retryOnFail(); } @Override diff --git a/app/src/main/java/io/xpipe/app/storage/DataStorage.java b/app/src/main/java/io/xpipe/app/storage/DataStorage.java index 40adb561b..3c795adda 100644 --- a/app/src/main/java/io/xpipe/app/storage/DataStorage.java +++ b/app/src/main/java/io/xpipe/app/storage/DataStorage.java @@ -476,9 +476,11 @@ public abstract class DataStorage { for (DataStoreEntry other : otherToFinalize) { other.finalizeEntry(); + SecretManager.clearAll(other.getUuid()); } entry.finalizeEntry(); + SecretManager.clearAll(entry.getUuid()); } public Set> getDependencies(DataStoreEntry entry) {