mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-28 23:31:43 +12:00
Rework fixed child handling for k8s improvements
This commit is contained in:
parent
53926a2830
commit
afc34a37b5
6 changed files with 57 additions and 18 deletions
|
@ -48,6 +48,8 @@ public class SentryErrorHandler implements ErrorHandler {
|
|||
options.setTag("arch", System.getProperty("os.arch"));
|
||||
options.setDist(XPipeDistributionType.get().getId());
|
||||
options.setTag("staging", String.valueOf(AppProperties.get().isStaging()));
|
||||
options.setCacheDirPath(AppProperties.get().getDataDir().resolve("cache").toString());
|
||||
options.setAttachThreads(false);
|
||||
});
|
||||
}
|
||||
init = true;
|
||||
|
|
|
@ -270,28 +270,48 @@ public abstract class DataStorage {
|
|||
.filter(other -> e.equals(getDefaultDisplayParent(other).orElse(null)))
|
||||
.toList();
|
||||
var toRemove = oldChildren.stream()
|
||||
.filter(entry -> newChildren.stream()
|
||||
.noneMatch(
|
||||
nc -> nc.getStore().getFixedId() == ((FixedChildStore) entry.getStore()).getFixedId()))
|
||||
.filter(oc -> {
|
||||
var oid = ((FixedChildStore) oc.getStore()).getFixedId();
|
||||
if (oid.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return newChildren.stream().filter(nc -> nc.getStore().getFixedId().isPresent()).noneMatch(nc -> {
|
||||
return nc.getStore().getFixedId().getAsInt() == oid.getAsInt();
|
||||
});
|
||||
})
|
||||
.toList();
|
||||
var toAdd = newChildren.stream()
|
||||
.filter(entry -> oldChildren.stream()
|
||||
.noneMatch(oc -> ((FixedChildStore) oc.getStore()).getFixedId()
|
||||
== entry.getStore().getFixedId()))
|
||||
.filter(nc -> {
|
||||
var nid = nc.getStore().getFixedId();
|
||||
// These can't be automatically generated
|
||||
if (nid.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return oldChildren.stream().filter(oc -> ((FixedChildStore) oc.getStore()).getFixedId().isPresent()).noneMatch(oc -> {
|
||||
return ((FixedChildStore) oc.getStore()).getFixedId().getAsInt() == nid.getAsInt();
|
||||
});
|
||||
})
|
||||
.toList();
|
||||
var toUpdate = oldChildren.stream()
|
||||
.map(entry -> {
|
||||
.map(oc -> {
|
||||
var oid = ((FixedChildStore) oc.getStore()).getFixedId();
|
||||
if (oid.isEmpty()) {
|
||||
return new Pair<DataStoreEntry, DataStoreEntryRef<? extends FixedChildStore>>(oc, null);
|
||||
}
|
||||
|
||||
var found = newChildren.stream()
|
||||
.filter(nc ->
|
||||
nc.getStore().getFixedId() == ((FixedChildStore) entry.getStore()).getFixedId())
|
||||
.filter(nc -> nc.getStore().getFixedId().isPresent())
|
||||
.filter(nc -> nc.getStore().getFixedId().getAsInt() == oid.getAsInt())
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
return new Pair<DataStoreEntry, DataStoreEntryRef<? extends FixedChildStore>>(entry, found);
|
||||
return new Pair<DataStoreEntry, DataStoreEntryRef<? extends FixedChildStore>>(oc, found);
|
||||
})
|
||||
.filter(en -> en.getValue() != null)
|
||||
.toList();
|
||||
|
||||
if (newChildren.size() > 0) {
|
||||
if (!newChildren.isEmpty()) {
|
||||
e.setExpanded(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -144,6 +144,11 @@ public class OptionsBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public OptionsBuilder disable(boolean b) {
|
||||
lastCompHeadReference.disable(new SimpleBooleanProperty(b));
|
||||
return this;
|
||||
}
|
||||
|
||||
public OptionsBuilder nonNull() {
|
||||
var e = lastNameReference;
|
||||
var p = props.get(props.size() - 1);
|
||||
|
|
|
@ -4,6 +4,7 @@ import lombok.Getter;
|
|||
import lombok.SneakyThrows;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class CommandBuilder {
|
||||
|
||||
|
@ -170,6 +171,21 @@ public class CommandBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public CommandBuilder addFile(Function<ShellControl, String> f) {
|
||||
elements.add(sc -> {
|
||||
if (f == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (sc == null) {
|
||||
return "\"" + f.apply(null) + "\"";
|
||||
}
|
||||
|
||||
return sc.getShellDialect().fileArgument(f.apply(sc));
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandBuilder addFiles(SequencedCollection<String> s) {
|
||||
s.forEach(this::addFile);
|
||||
return this;
|
||||
|
|
|
@ -144,12 +144,6 @@ public interface ShellControl extends ProcessControl {
|
|||
}
|
||||
}
|
||||
|
||||
default String executeSimpleStringCommand(ShellDialect type, String command) throws Exception {
|
||||
try (var sub = subShell(type).start()) {
|
||||
return sub.executeSimpleStringCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
ElevationResult buildElevatedCommand(CommandConfiguration input, String prefix) throws Exception;
|
||||
|
||||
void restart() throws Exception;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package io.xpipe.core.store;
|
||||
|
||||
import java.util.OptionalInt;
|
||||
|
||||
public interface FixedChildStore extends DataStore {
|
||||
|
||||
int getFixedId();
|
||||
OptionalInt getFixedId();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue