diff --git a/app/src/main/java/io/xpipe/app/beacon/impl/ConnectionRefreshExchangeImpl.java b/app/src/main/java/io/xpipe/app/beacon/impl/ConnectionRefreshExchangeImpl.java index 1b33eee84..3c97868e9 100644 --- a/app/src/main/java/io/xpipe/app/beacon/impl/ConnectionRefreshExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/beacon/impl/ConnectionRefreshExchangeImpl.java @@ -15,7 +15,7 @@ public class ConnectionRefreshExchangeImpl extends ConnectionRefreshExchange { .getStoreEntryIfPresent(msg.getConnection()) .orElseThrow(() -> new BeaconClientException("Unknown connection: " + msg.getConnection())); if (e.getStore() instanceof FixedHierarchyStore) { - DataStorage.get().refreshChildren(e, true); + DataStorage.get().refreshChildren(e, null, true); } else { e.validateOrThrowAndClose(null); } diff --git a/app/src/main/java/io/xpipe/app/comp/store/StoreEntryWrapper.java b/app/src/main/java/io/xpipe/app/comp/store/StoreEntryWrapper.java index a2111fbf8..efd436fa2 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StoreEntryWrapper.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StoreEntryWrapper.java @@ -216,7 +216,7 @@ public class StoreEntryWrapper { } public void refreshChildren() { - var hasChildren = DataStorage.get().refreshChildren(entry); + var hasChildren = DataStorage.get().refreshChildren(entry, null); PlatformThread.runLaterIfNeeded(() -> { expanded.set(hasChildren); }); 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 df8f11833..9fcb91230 100644 --- a/app/src/main/java/io/xpipe/app/storage/DataStorage.java +++ b/app/src/main/java/io/xpipe/app/storage/DataStorage.java @@ -353,23 +353,25 @@ public abstract class DataStorage { } @SneakyThrows - public boolean refreshChildren(DataStoreEntry e) { - return refreshChildren(e, false); + public boolean refreshChildren(DataStoreEntry e, ValidationContext context) { + return refreshChildren(e, context, false); } @SuppressWarnings("unchecked") - public > boolean refreshChildren(DataStoreEntry e, boolean throwOnFail) throws Exception { + public > boolean refreshChildren(DataStoreEntry e, T context, boolean throwOnFail) throws Exception { if (!(e.getStore() instanceof FixedHierarchyStore h)) { return false; } e.incrementBusyCounter(); List> newChildren; - T context = null; + var hadContext = context != null; try { - context = (T) h.createContext(); if (context == null) { - return false; + context = (T) h.createContext(); + if (context == null) { + return false; + } } newChildren = ((FixedHierarchyStore)h).listChildren(context).stream() @@ -383,7 +385,7 @@ public abstract class DataStorage { return false; } } finally { - if (context != null) { + if (context != null && !hadContext) { context.close(); } e.decrementBusyCounter(); diff --git a/ext/base/src/main/java/io/xpipe/ext/base/action/RefreshChildrenStoreAction.java b/ext/base/src/main/java/io/xpipe/ext/base/action/RefreshChildrenStoreAction.java index f4f21895a..4ee84ef54 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/action/RefreshChildrenStoreAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/action/RefreshChildrenStoreAction.java @@ -72,7 +72,7 @@ public class RefreshChildrenStoreAction implements ActionProvider { @Override public void execute() { - DataStorage.get().refreshChildren(store); + DataStorage.get().refreshChildren(store, null); } } }