Various fixes

This commit is contained in:
crschnick 2024-02-23 08:53:18 +00:00
parent 7da334bd65
commit db36741c15
3 changed files with 7 additions and 10 deletions

View file

@ -49,7 +49,7 @@ public interface ShellDialect {
String prepareTerminalEnvironmentCommands(); String prepareTerminalEnvironmentCommands();
String addToPathVariableCommand(List<String> entry, boolean append); String addToPathVariableCommand(List<String> entries, boolean append);
default String applyRcFileCommand() { default String applyRcFileCommand() {
return null; return null;

View file

@ -42,12 +42,6 @@ public class XPipeInstallation {
return Path.of(System.getProperty("user.home"), isStaging() ? ".xpipe-ptb" : ".xpipe"); return Path.of(System.getProperty("user.home"), isStaging() ? ".xpipe-ptb" : ".xpipe");
} }
public static String getDataDir(ShellControl p) throws Exception {
var name = isStaging() ? ".xpipe-ptb" : ".xpipe";
var dir = p.getOsType().getHomeDirectory(p);
return FileNames.join(dir, name);
}
private static String getPkgId() { private static String getPkgId() {
return isStaging() ? "io.xpipe.xpipe-ptb" : "io.xpipe.xpipe"; return isStaging() ? "io.xpipe.xpipe-ptb" : "io.xpipe.xpipe";
} }

View file

@ -13,7 +13,6 @@ import io.xpipe.core.store.DataStoreState;
import io.xpipe.core.store.FileNames; import io.xpipe.core.store.FileNames;
import io.xpipe.core.store.StatefulDataStore; import io.xpipe.core.store.StatefulDataStore;
import io.xpipe.core.util.JacksonizedValue; import io.xpipe.core.util.JacksonizedValue;
import io.xpipe.core.util.XPipeInstallation;
import lombok.*; import lombok.*;
import lombok.experimental.FieldDefaults; import lombok.experimental.FieldDefaults;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
@ -42,6 +41,11 @@ public abstract class ScriptStore extends JacksonizedValue implements DataStore,
List<DataStoreEntryRef<ScriptStore>> initScripts, List<DataStoreEntryRef<ScriptStore>> initScripts,
List<DataStoreEntryRef<ScriptStore>> bringScripts) { List<DataStoreEntryRef<ScriptStore>> bringScripts) {
try { try {
// Don't copy scripts if we don't want to modify the file system
if (!pc.getEffectiveSecurityPolicy().permitTempScriptCreation()) {
return pc;
}
var initFlattened = flatten(initScripts); var initFlattened = flatten(initScripts);
var bringFlattened = flatten(bringScripts); var bringFlattened = flatten(bringScripts);
@ -109,9 +113,8 @@ public abstract class ScriptStore extends JacksonizedValue implements DataStore,
.mapToInt(value -> .mapToInt(value ->
value.get().getName().hashCode() + value.getStore().hashCode()) value.get().getName().hashCode() + value.getStore().hashCode())
.sum(); .sum();
var xpipeHome = XPipeInstallation.getDataDir(proc);
var targetDir = var targetDir =
FileNames.join(xpipeHome, "scripts", proc.getShellDialect().getId()); FileNames.join(proc.getSystemTemporaryDirectory(), "xpipe", "scripts", proc.getShellDialect().getId());
var hashFile = FileNames.join(targetDir, "hash"); var hashFile = FileNames.join(targetDir, "hash");
var d = proc.getShellDialect(); var d = proc.getShellDialect();
if (d.createFileExistsCommand(proc, hashFile).executeAndCheck()) { if (d.createFileExistsCommand(proc, hashFile).executeAndCheck()) {