mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
Validation fixes
This commit is contained in:
parent
39f32af927
commit
acb2583100
4 changed files with 12 additions and 10 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -353,24 +353,26 @@ 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 <T extends ValidationContext<?>> boolean refreshChildren(DataStoreEntry e, boolean throwOnFail) throws Exception {
|
||||
public <T extends ValidationContext<?>> boolean refreshChildren(DataStoreEntry e, T context, boolean throwOnFail) throws Exception {
|
||||
if (!(e.getStore() instanceof FixedHierarchyStore<?> h)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
e.incrementBusyCounter();
|
||||
List<? extends DataStoreEntryRef<? extends FixedChildStore>> newChildren;
|
||||
T context = null;
|
||||
var hadContext = context != null;
|
||||
try {
|
||||
if (context == null) {
|
||||
context = (T) h.createContext();
|
||||
if (context == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
newChildren = ((FixedHierarchyStore<T>)h).listChildren(context).stream()
|
||||
.filter(dataStoreEntryRef -> dataStoreEntryRef != null && dataStoreEntryRef.get() != null)
|
||||
|
@ -383,7 +385,7 @@ public abstract class DataStorage {
|
|||
return false;
|
||||
}
|
||||
} finally {
|
||||
if (context != null) {
|
||||
if (context != null && !hadContext) {
|
||||
context.close();
|
||||
}
|
||||
e.decrementBusyCounter();
|
||||
|
|
|
@ -72,7 +72,7 @@ public class RefreshChildrenStoreAction implements ActionProvider {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
DataStorage.get().refreshChildren(store);
|
||||
DataStorage.get().refreshChildren(store, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue