Always close fs shell on fail

This commit is contained in:
crschnick committed 2026-10-04 11:19:16 +00:00
1 parent 19a1248866
commit cc25ea1fd1
2 files changed
+30 -24

No files matched your search

@@ -166,32 +166,37 @@ public final class BrowserFileSystemTabModel extends BrowserStoreSessionTab<File
public void init() throws Exception {
BooleanScope.executeExclusive(busy, () -> {
var fs = new WrapperFileSystem(fileSystemFactory.apply(getEntry().asNeeded()));
Platform.runLater(() -> {
getFileSystemNameSuffix().set(fs.getSuffix());
});
if (fs.getShell().isPresent()) {
ProcModuleProvider.get().withDefaultScripts(fs.getShell().get());
}
fs.open();
// Listen to kill after init as the shell might get killed during init for certain reasons
if (fs.getRawShellControl().isPresent()) {
fs.getRawShellControl().get().onKill(() -> {
browserModel.closeAsync(this);
try {
Platform.runLater(() -> {
getFileSystemNameSuffix().set(fs.getSuffix());
});
}
this.fileSystem = fs;
// Cache for later usage
if (fs.getShell().isPresent()) {
fs.getShell().get().view().getPasswdFile();
fs.getShell().get().view().getGroupFile();
}
for (var a : ActionProvider.ALL) {
if (a instanceof BrowserMenuItemProvider ba) {
ba.init(this);
if (fs.getShell().isPresent()) {
ProcModuleProvider.get().withDefaultScripts(fs.getShell().get());
}
fs.open();
// Listen to kill after init as the shell might get killed during init for certain reasons
if (fs.getRawShellControl().isPresent()) {
fs.getRawShellControl().get().onKill(() -> {
browserModel.closeAsync(this);
});
}
this.fileSystem = fs;
// Cache for later usage
if (fs.getShell().isPresent()) {
fs.getShell().get().view().getPasswdFile();
fs.getShell().get().view().getGroupFile();
}
for (var a : ActionProvider.ALL) {
if (a instanceof BrowserMenuItemProvider ba) {
ba.init(this);
}
}
} catch (Exception e) {
fs.close();
throw e;
}
});
this.savedState = BrowserFileSystemSavedState.loadForStore(this);
@@ -247,6 +247,7 @@ public class ShellFileSystem implements FileSystem {
if (!shellControl.getTtyState().isPreservesOutput()
|| !shellControl.getTtyState().isSupportsInput()) {
shellControl.close();
var ex = new UnsupportedOperationException(
"Shell has a PTY allocated and as a result does not support file system operations.");
ErrorEventFactory.preconfigure(