diff --git a/core/src/main/java/io/xpipe/core/process/ShellDumbMode.java b/core/src/main/java/io/xpipe/core/process/ShellDumbMode.java index 20573ed72..3faa460c2 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellDumbMode.java +++ b/core/src/main/java/io/xpipe/core/process/ShellDumbMode.java @@ -8,6 +8,8 @@ public interface ShellDumbMode { return true; } + default void throwIfUnsupported() {} + default ShellDialect getSwitchDialect() { return null; } @@ -25,6 +27,14 @@ public interface ShellDumbMode { class Unsupported implements ShellDumbMode { + private final String message; + + public Unsupported(String message) {this.message = message;} + + public void throwIfUnsupported() { + throw new UnsupportedOperationException(message); + } + @Override public boolean supportsAnyPossibleInteraction() { return false; diff --git a/core/src/main/java/io/xpipe/core/store/ConnectionFileSystem.java b/core/src/main/java/io/xpipe/core/store/ConnectionFileSystem.java index 22f0f42a3..c5331bbc9 100644 --- a/core/src/main/java/io/xpipe/core/store/ConnectionFileSystem.java +++ b/core/src/main/java/io/xpipe/core/store/ConnectionFileSystem.java @@ -1,9 +1,8 @@ package io.xpipe.core.store; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.xpipe.core.process.CommandBuilder; import io.xpipe.core.process.ShellControl; - -import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import java.io.InputStream; @@ -37,9 +36,10 @@ public class ConnectionFileSystem implements FileSystem { @Override public FileSystem open() throws Exception { shellControl.start(); - if (!shellControl.getShellDialect().getDumbMode().supportsAnyPossibleInteraction()) { + var d = shellControl.getShellDialect().getDumbMode(); + if (!d.supportsAnyPossibleInteraction()) { shellControl.close(); - throw new UnsupportedOperationException("System shell does not support file system interaction"); + d.throwIfUnsupported(); } return this; }