mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 17:10:27 +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())
|
.getStoreEntryIfPresent(msg.getConnection())
|
||||||
.orElseThrow(() -> new BeaconClientException("Unknown connection: " + msg.getConnection()));
|
.orElseThrow(() -> new BeaconClientException("Unknown connection: " + msg.getConnection()));
|
||||||
if (e.getStore() instanceof FixedHierarchyStore) {
|
if (e.getStore() instanceof FixedHierarchyStore) {
|
||||||
DataStorage.get().refreshChildren(e, true);
|
DataStorage.get().refreshChildren(e, null, true);
|
||||||
} else {
|
} else {
|
||||||
e.validateOrThrowAndClose(null);
|
e.validateOrThrowAndClose(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,7 @@ public class StoreEntryWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshChildren() {
|
public void refreshChildren() {
|
||||||
var hasChildren = DataStorage.get().refreshChildren(entry);
|
var hasChildren = DataStorage.get().refreshChildren(entry, null);
|
||||||
PlatformThread.runLaterIfNeeded(() -> {
|
PlatformThread.runLaterIfNeeded(() -> {
|
||||||
expanded.set(hasChildren);
|
expanded.set(hasChildren);
|
||||||
});
|
});
|
||||||
|
|
|
@ -353,23 +353,25 @@ public abstract class DataStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public boolean refreshChildren(DataStoreEntry e) {
|
public boolean refreshChildren(DataStoreEntry e, ValidationContext<?> context) {
|
||||||
return refreshChildren(e, false);
|
return refreshChildren(e, context, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@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)) {
|
if (!(e.getStore() instanceof FixedHierarchyStore<?> h)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
e.incrementBusyCounter();
|
e.incrementBusyCounter();
|
||||||
List<? extends DataStoreEntryRef<? extends FixedChildStore>> newChildren;
|
List<? extends DataStoreEntryRef<? extends FixedChildStore>> newChildren;
|
||||||
T context = null;
|
var hadContext = context != null;
|
||||||
try {
|
try {
|
||||||
context = (T) h.createContext();
|
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
return false;
|
context = (T) h.createContext();
|
||||||
|
if (context == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newChildren = ((FixedHierarchyStore<T>)h).listChildren(context).stream()
|
newChildren = ((FixedHierarchyStore<T>)h).listChildren(context).stream()
|
||||||
|
@ -383,7 +385,7 @@ public abstract class DataStorage {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (context != null) {
|
if (context != null && !hadContext) {
|
||||||
context.close();
|
context.close();
|
||||||
}
|
}
|
||||||
e.decrementBusyCounter();
|
e.decrementBusyCounter();
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class RefreshChildrenStoreAction implements ActionProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
DataStorage.get().refreshChildren(store);
|
DataStorage.get().refreshChildren(store, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue