Rework shell control to be more robust in cases it exits unexpectedly

This commit is contained in:
crschnick 2024-01-09 23:17:18 +00:00
parent a6cb7b1a30
commit faf1b6b4c7
5 changed files with 12 additions and 3 deletions

View file

@ -53,7 +53,7 @@ public class FileSystemHelper {
}
var shell = model.getFileSystem().getShell();
if (shell.isEmpty()) {
if (shell.isEmpty() || !shell.get().isRunning()) {
return path;
}

View file

@ -131,6 +131,9 @@ public final class OpenFileSystemModel {
return Optional.empty();
}
// Start shell in case we exited
getFileSystem().getShell().orElseThrow().start();
// Fix common issues with paths
var adjustedPath = FileSystemHelper.adjustPath(this, path);
if (!Objects.equals(path, adjustedPath)) {

View file

@ -29,6 +29,8 @@ public interface LeafAction extends BrowserAction {
ThreadHelper.runFailableAsync(() -> {
BooleanScope.execute(model.getBusy(), () -> {
// Start shell in case we exited
model.getFileSystem().getShell().orElseThrow().start();
execute(model, selected);
});
});
@ -64,6 +66,8 @@ public interface LeafAction extends BrowserAction {
mi.setOnAction(event -> {
ThreadHelper.runFailableAsync(() -> {
BooleanScope.execute(model.getBusy(), () -> {
// Start shell in case we exited
model.getFileSystem().getShell().orElseThrow().start();
execute(model, selected);
});
});

View file

@ -14,7 +14,7 @@ public interface ProcessControl extends AutoCloseable {
ProcessControl withExceptionConverter(ExceptionConverter converter);
void resetData();
void resetData(boolean cache);
String prepareTerminalOpen(TerminalInitScriptConfig config) throws Exception;
@ -33,7 +33,7 @@ public interface ProcessControl extends AutoCloseable {
@Override
void close() throws Exception;
void kill() throws Exception;
void kill();
ProcessControl start() throws Exception;

View file

@ -16,6 +16,8 @@ import java.util.function.Function;
public interface ShellControl extends ProcessControl {
List<UUID> getExitUuids();
Optional<ShellStore> getSourceStore();
ShellControl withSourceStore(ShellStore store);