From 568e06f8da97f706a91b8f5b025db8227791b68a Mon Sep 17 00:00:00 2001 From: crschnick Date: Fri, 12 Jun 2026 21:54:40 +0000 Subject: [PATCH] Improve api store update --- .../beacon/impl/ConnectionAddExchangeImpl.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/beacon/impl/ConnectionAddExchangeImpl.java b/app/src/main/java/io/xpipe/app/beacon/impl/ConnectionAddExchangeImpl.java index 84e4af9a5..6c0ea16e1 100644 --- a/app/src/main/java/io/xpipe/app/beacon/impl/ConnectionAddExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/beacon/impl/ConnectionAddExchangeImpl.java @@ -20,14 +20,19 @@ public class ConnectionAddExchangeImpl extends ConnectionAddExchange { throw new BeaconClientException("Unable to parse store data into valid store"); } - var found = DataStorage.get().getStoreEntryIfPresent(store, false); - if (found.isEmpty()) { - found = DataStorage.get().getStoreEntryIfPresent(msg.getName()); + var foundStore = DataStorage.get().getStoreEntryIfPresent(store, false); + if (foundStore.isPresent()) { + return Response.builder().connection(foundStore.get().getUuid()).build(); } - if (found.isPresent()) { - DataStorage.get().updateEntryStore(found.get(), store); - return Response.builder().connection(found.get().getUuid()).build(); + var foundName = DataStorage.get().getStoreEntryIfPresent(msg.getName()); + if (foundName.isPresent()) { + var foundNameStore = foundName.get().getStore(); + // Only allow updates for the same type of store + if (foundNameStore != null && foundNameStore.getClass().equals(store.getClass())) { + DataStorage.get().updateEntryStore(foundName.get(), store); + return Response.builder().connection(foundName.get().getUuid()).build(); + } } if (msg.getCategory() != null