Various fixes

This commit is contained in:
crschnick committed 2026-09-27 15:00:07 +00:00
1 parent 37ff49cdf2
commit 76dd573cc7
4 files changed
+26 -28

No files matched your search

@@ -59,7 +59,7 @@ public class StoreEntryInformation {
}
if (s.getTtyState() != null && s.getTtyState() != ShellTtyState.NONE) {
l.add(StoreEntryBadge.ofConnectionType("TTY"));
l.add(StoreEntryBadge.ofFailure("TTY"));
}
return StoreEntryInformation.of(l);
@@ -108,7 +108,7 @@ public interface ShellControl extends ProcessControl {
var oldState = store.getState();
var newState = oldState.toBuilder()
.shellDialect(or.isMarkerDialect() ? oldState.getShellDialect() : or)
.ttyState(shellControl.getTtyState())
.ttyState(or.isMarkerDialect() ? oldState.getTtyState() : shellControl.getTtyState())
.running(true);
if (shellControl.getOsType() != null) {
newState.osType(shellControl.getOsType());
@@ -24,7 +24,7 @@ public class ShellTemp {
}
}
public static FilePath createUserSpecificTempDataDirectory(ShellControl proc) throws Exception {
private static void initUserSpecificTempDataDirectory(ShellControl proc) throws Exception {
var base = getUserSpecificTempDataDirectoryPath(proc);
// On Windows and macOS, we already have user specific temp directories
// Even on macOS as root is technically unique as only root will use /tmp
@@ -35,7 +35,7 @@ public class ShellTemp {
// This command should work in all shells
var hasChmod = proc.view().findProgram("chmod").isPresent();
if (hasChmod) {
var chmodSuccess = proc.executeRobustBootstrapCommand("chmod 700 " + proc.getShellDialect().fileArgument(base)).isPresent();
var chmodSuccess = proc.command("chmod 700 " + proc.getShellDialect().fileArgument(base)).executeAndCheck();
if (!chmodSuccess) {
throw new IOException("Unexpected directory ownership and permissions for " + base);
}
@@ -61,11 +61,7 @@ public class ShellTemp {
}
}
}
}
return base;
} else {
return base;
}
}
@@ -85,29 +81,31 @@ public class ShellTemp {
return hasValidTemp;
}
public static FilePath createSubTempDirectory(ShellControl sc, boolean hasValidTemp) throws Exception {
if (!hasValidTemp) {
return null;
}
public static void checkSubTempDirectory(ShellControl sc, boolean hasValidTemp) throws Exception {
var subTemp = sc.getSubTemporaryDirectory();
if (hasValidTemp) {
// When starting up multiple sessions to the same system, there might be race conditions here
// This is quite inefficient but there is no way to synchronize access on a
// specific system when multiple shell controls access it
synchronized (ShellTemp.class) {
var sessionFile = subTemp.join("xpipe-session-"
+ AppProperties.get().getSessionId().toString().substring(0, 8));
var newSession = !sc.view().fileExists(sessionFile);
if (newSession) {
clearTemp(sc);
try {
sc.view().mkdir(subTemp);
sc.view().touch(sessionFile);
} catch (ProcessOutputException pex) {
if (!pex.getOutput().toLowerCase().contains("no space left on device")) {
throw pex;
}
// When starting up multiple sessions to the same system, there might be race conditions here
// This is quite inefficient but there is no way to synchronize access on a
// specific system when multiple shell controls access it
synchronized (ShellTemp.class) {
var subTemp = getUserSpecificTempDataDirectoryPath(sc);
var sessionFile = subTemp.join("xpipe-session-"
+ AppProperties.get().getSessionId().toString().substring(0, 8));
var newSession = !sc.view().fileExists(sessionFile);
if (newSession) {
clearTemp(sc);
initUserSpecificTempDataDirectory(sc);
try {
sc.view().touch(sessionFile);
} catch (ProcessOutputException pex) {
if (!pex.getOutput().toLowerCase().contains("no space left on device")) {
throw pex;
}
}
}
return subTemp;
}
}
@@ -37,7 +37,7 @@ public class CustomTerminalType implements ExternalApplicationType, ExternalTerm
var format = custom.toLowerCase(Locale.ROOT).contains("$cmd") ? custom : custom + " $CMD";
try (var sc = LocalShell.getShell()) {
var toExecute = ExternalApplicationHelper.replaceVariableArgument(
format, "CMD", configuration.single().getScriptFile().toString(), false);
format, "CMD", configuration.single().getScriptFile().toString(), true);
// We can't be sure whether the command is blocking or not, so always make it not blocking
if (sc.getOsType() == OsType.WINDOWS) {
toExecute = "start \"" + configuration.getCleanTitle() + "\" " + toExecute;