Various fixes

This commit is contained in:
crschnick 2024-02-22 05:21:24 +00:00
parent 68d3c4263b
commit 12e4ccb995
6 changed files with 20 additions and 9 deletions

View file

@ -67,13 +67,15 @@ public final class OpenFileSystemModel {
&& fileSystem.getShell().get().getLock().isLocked());
}
private void startIfNeeded() {
private void startIfNeeded() throws Exception {
if (fileSystem == null) {
return;
}
var s = fileSystem.getShell();
s.ifPresent(ShellControl::start);
if (s.isPresent()) {
s.get().start();
}
}
public void withShell(FailableConsumer<ShellControl, Exception> c, boolean refresh) {
@ -151,8 +153,13 @@ public final class OpenFileSystemModel {
return Optional.empty();
}
// Start shell in case we exited
startIfNeeded();
try {
// Start shell in case we exited
startIfNeeded();
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
return Optional.ofNullable(currentPath.get());
}
// Fix common issues with paths
var adjustedPath = FileSystemHelper.adjustPath(this, path);

View file

@ -85,6 +85,10 @@ public class ErrorEvent {
return t;
}
public static void preconfigure(ErrorEventBuilder event) {
EVENT_BASES.put(event.throwable, event);
}
public void attachUserReport(String email, String text) {
this.email = email;
userReport = text;

View file

@ -13,12 +13,12 @@ public class LocalShell {
private static ShellControl local;
private static ShellControl localPowershell;
public static void init() {
public static void init() throws Exception {
local = ProcessControlProvider.get().createLocalProcessControl(false).start();
localCache = new ShellControlCache(local);
}
public static ShellControl getLocalPowershell() {
public static ShellControl getLocalPowershell() throws Exception {
if (localPowershell == null) {
localPowershell = ProcessControlProvider.get()
.createLocalProcessControl(true)

View file

@ -76,7 +76,7 @@ public interface ShellControl extends ProcessControl {
ShellControl withExceptionConverter(ExceptionConverter converter);
@Override
ShellControl start();
ShellControl start() throws Exception;
ShellControl withErrorFormatter(Function<String, String> formatter);

View file

@ -36,7 +36,7 @@ public class ConnectionFileSystem implements FileSystem {
}
@Override
public FileSystem open() {
public FileSystem open() throws Exception {
shellControl.start();
return this;
}

View file

@ -21,7 +21,7 @@ public interface FileSystem extends Closeable, AutoCloseable {
Optional<ShellControl> getShell();
FileSystem open();
FileSystem open() throws Exception;
InputStream openInput(String file) throws Exception;