mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-29 04:36:31 +00:00
Rework
This commit is contained in:
@@ -5,7 +5,7 @@ import io.xpipe.app.beacon.AppBeaconServer;
|
||||
import io.xpipe.app.beacon.BeaconClientException;
|
||||
import io.xpipe.app.beacon.BeaconInterface;
|
||||
import io.xpipe.app.beacon.BlobManager;
|
||||
import io.xpipe.app.ext.ConnectionFileSystem;
|
||||
import io.xpipe.app.ext.ShellFileSystem;
|
||||
import io.xpipe.app.util.FilePath;
|
||||
|
||||
import io.xpipe.app.util.FixedSizeInputStream;
|
||||
@@ -31,7 +31,7 @@ public class FsReadExchange extends BeaconInterface<FsReadExchange.Request> {
|
||||
@SneakyThrows
|
||||
public Object handle(HttpExchange exchange, Request msg) {
|
||||
var shell = AppBeaconServer.get().getCache().getShellSession(msg.getStore());
|
||||
var fs = new ConnectionFileSystem(shell.getControl());
|
||||
var fs = new ShellFileSystem(shell.getControl());
|
||||
|
||||
if (!fs.fileExists(msg.getPath())) {
|
||||
throw new BeaconClientException("File does not exist");
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.sun.net.httpserver.HttpExchange;
|
||||
import io.xpipe.app.beacon.AppBeaconServer;
|
||||
import io.xpipe.app.beacon.BeaconInterface;
|
||||
import io.xpipe.app.beacon.BlobManager;
|
||||
import io.xpipe.app.ext.ConnectionFileSystem;
|
||||
import io.xpipe.app.ext.ShellFileSystem;
|
||||
import io.xpipe.app.util.FilePath;
|
||||
|
||||
import lombok.Builder;
|
||||
@@ -13,7 +13,6 @@ import lombok.SneakyThrows;
|
||||
import lombok.Value;
|
||||
import lombok.extern.jackson.Jacksonized;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FsWriteExchange extends BeaconInterface<FsWriteExchange.Request> {
|
||||
@@ -27,7 +26,7 @@ public class FsWriteExchange extends BeaconInterface<FsWriteExchange.Request> {
|
||||
@SneakyThrows
|
||||
public Object handle(HttpExchange exchange, Request msg) {
|
||||
var shell = AppBeaconServer.get().getCache().getShellSession(msg.getStore());
|
||||
var fs = new ConnectionFileSystem(shell.getControl());
|
||||
var fs = new ShellFileSystem(shell.getControl());
|
||||
try (var in = BlobManager.get().getBlob(msg.getBlob());
|
||||
var os = fs.openOutput(msg.getPath(), BlobManager.get().getSize(msg.getBlob()))) {
|
||||
in.transferTo(os);
|
||||
|
||||
@@ -184,7 +184,7 @@ public final class McpTools {
|
||||
var shellStore = req.getShellStoreRef(system, false);
|
||||
var shellSession = AppBeaconServer.get().getCache().getOrStart(shellStore);
|
||||
var path = req.getFilePath(shellSession.getControl(), "path");
|
||||
var fs = new ConnectionFileSystem(shellSession.getControl());
|
||||
var fs = new ShellFileSystem(shellSession.getControl());
|
||||
|
||||
if (!fs.fileExists(path)) {
|
||||
throw new BeaconClientException("File " + path + " does not exist");
|
||||
@@ -210,7 +210,7 @@ public final class McpTools {
|
||||
var recursive = req.getOptionalBooleanArgument("recursive").orElse(false);
|
||||
var shellStore = req.getShellStoreRef(system, false);
|
||||
var shellSession = AppBeaconServer.get().getCache().getOrStart(shellStore);
|
||||
var fs = new ConnectionFileSystem(shellSession.getControl());
|
||||
var fs = new ShellFileSystem(shellSession.getControl());
|
||||
var path = req.getFilePath(shellSession.getControl(), "path");
|
||||
|
||||
if (!fs.directoryExists(path)) {
|
||||
@@ -239,7 +239,7 @@ public final class McpTools {
|
||||
var shellStore = req.getShellStoreRef(system, false);
|
||||
var shellSession = AppBeaconServer.get().getCache().getOrStart(shellStore);
|
||||
var path = req.getFilePath(shellSession.getControl(), "path");
|
||||
var fs = new ConnectionFileSystem(shellSession.getControl());
|
||||
var fs = new ShellFileSystem(shellSession.getControl());
|
||||
|
||||
if (!fs.directoryExists(path)) {
|
||||
throw new BeaconClientException("Directory " + path + " does not exist");
|
||||
@@ -271,7 +271,7 @@ public final class McpTools {
|
||||
var shellStore = req.getShellStoreRef(system, false);
|
||||
var shellSession = AppBeaconServer.get().getCache().getOrStart(shellStore);
|
||||
var path = req.getFilePath(shellSession.getControl(), "path");
|
||||
var fs = new ConnectionFileSystem(shellSession.getControl());
|
||||
var fs = new ShellFileSystem(shellSession.getControl());
|
||||
|
||||
if (!fs.fileExists(path) && !fs.directoryExists(path)) {
|
||||
throw new BeaconClientException("Path " + path + " does not exist");
|
||||
@@ -312,7 +312,7 @@ public final class McpTools {
|
||||
var shellStore = req.getShellStoreRef(system, true);
|
||||
var shellSession = AppBeaconServer.get().getCache().getOrStart(shellStore);
|
||||
var path = req.getFilePath(shellSession.getControl(), "path");
|
||||
var fs = new ConnectionFileSystem(shellSession.getControl());
|
||||
var fs = new ShellFileSystem(shellSession.getControl());
|
||||
|
||||
if (fs.fileExists(path)) {
|
||||
throw new BeaconClientException("File " + path + " does already exist");
|
||||
@@ -345,7 +345,7 @@ public final class McpTools {
|
||||
var shellStore = req.getShellStoreRef(system, true);
|
||||
var shellSession = AppBeaconServer.get().getCache().getOrStart(shellStore);
|
||||
var path = req.getFilePath(shellSession.getControl(), "path");
|
||||
var fs = new ConnectionFileSystem(shellSession.getControl());
|
||||
var fs = new ShellFileSystem(shellSession.getControl());
|
||||
|
||||
var b = content.getBytes(StandardCharsets.UTF_8);
|
||||
try (var out = fs.openOutput(path, b.length)) {
|
||||
@@ -368,7 +368,7 @@ public final class McpTools {
|
||||
var shellStore = req.getShellStoreRef(system, true);
|
||||
var shellSession = AppBeaconServer.get().getCache().getOrStart(shellStore);
|
||||
var path = req.getFilePath(shellSession.getControl(), "path");
|
||||
var fs = new ConnectionFileSystem(shellSession.getControl());
|
||||
var fs = new ShellFileSystem(shellSession.getControl());
|
||||
|
||||
if (fs.fileExists(path)) {
|
||||
throw new BeaconClientException("Directory " + path + " does already exist");
|
||||
|
||||
@@ -200,6 +200,9 @@ public class BrowserFullSessionComp extends SimpleRegionBuilder {
|
||||
cache.keySet().removeIf(browserSessionTab -> !all.contains(browserSessionTab));
|
||||
|
||||
if (newValue == null) {
|
||||
struc.setMinWidth(0);
|
||||
struc.setPrefWidth(Region.USE_COMPUTED_SIZE);
|
||||
struc.setMaxWidth(Region.USE_COMPUTED_SIZE);
|
||||
struc.getChildren().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.xpipe.app.browser.file;
|
||||
|
||||
import io.xpipe.app.core.window.AppDialog;
|
||||
import io.xpipe.app.ext.ConnectionFileSystem;
|
||||
import io.xpipe.app.ext.ShellFileSystem;
|
||||
import io.xpipe.app.ext.FileEntry;
|
||||
import io.xpipe.app.ext.FileInfo;
|
||||
import io.xpipe.app.process.CommandBuilder;
|
||||
@@ -81,7 +81,7 @@ public interface BrowserFileInput {
|
||||
.elevated(ElevationFunction.elevated(null))
|
||||
.start()
|
||||
: model.getFileSystem().getShell().orElseThrow().start();
|
||||
var fs = elevate ? new ConnectionFileSystem(sc) : model.getFileSystem();
|
||||
var fs = elevate ? new ShellFileSystem(sc) : model.getFileSystem();
|
||||
var output = new BrowserFileInput() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.xpipe.app.browser.file;
|
||||
|
||||
import io.xpipe.app.core.window.AppDialog;
|
||||
import io.xpipe.app.ext.ConnectionFileSystem;
|
||||
import io.xpipe.app.ext.ShellFileSystem;
|
||||
import io.xpipe.app.ext.FileEntry;
|
||||
import io.xpipe.app.ext.FileInfo;
|
||||
import io.xpipe.app.issue.ErrorEventFactory;
|
||||
@@ -87,7 +87,7 @@ public interface BrowserFileOutput {
|
||||
.elevated(ElevationFunction.elevated(null))
|
||||
.start()
|
||||
: model.getFileSystem().getShell().orElseThrow().start();
|
||||
var fs = elevate ? new ConnectionFileSystem(sc) : model.getFileSystem();
|
||||
var fs = elevate ? new ShellFileSystem(sc) : model.getFileSystem();
|
||||
var checkSudoersFile = shell.isPresent() && file.getPath().startsWith("/etc/sudo");
|
||||
var output = new BrowserFileOutput() {
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ public class BrowserStatusBarComp extends SimpleRegionBuilder {
|
||||
createClipboardStatus(),
|
||||
createSelectionStatus(),
|
||||
createKillButton()));
|
||||
bar.minWidth(0);
|
||||
bar.spacing(15);
|
||||
bar.style("status-bar");
|
||||
|
||||
|
||||
+4
-4
@@ -25,12 +25,12 @@ import java.util.UUID;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Getter
|
||||
public class ConnectionFileSystem implements FileSystem {
|
||||
public class ShellFileSystem implements FileSystem {
|
||||
|
||||
@JsonIgnore
|
||||
protected final ShellControl shellControl;
|
||||
|
||||
public ConnectionFileSystem(ShellControl shellControl) {
|
||||
public ShellFileSystem(ShellControl shellControl) {
|
||||
this.shellControl = shellControl;
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public class ConnectionFileSystem implements FileSystem {
|
||||
.findProgram(ShellDialects.POWERSHELL_CORE.getExecutableName())
|
||||
.isPresent();
|
||||
if (pwsh) {
|
||||
return new ConnectionFileSystem(
|
||||
return new ShellFileSystem(
|
||||
shellControl.subShell(ShellDialects.POWERSHELL_CORE).start());
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ public class ConnectionFileSystem implements FileSystem {
|
||||
.findProgram(ShellDialects.POWERSHELL.getExecutableName())
|
||||
.isPresent();
|
||||
if (powershell) {
|
||||
return new ConnectionFileSystem(
|
||||
return new ShellFileSystem(
|
||||
shellControl.subShell(ShellDialects.POWERSHELL).start());
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public interface ShellStore extends DataStore, FileSystemStore, ValidatableStore
|
||||
@Override
|
||||
default FileSystem createFileSystem() throws Exception {
|
||||
var func = shellFunction();
|
||||
return new ConnectionFileSystem(func.control());
|
||||
return new ShellFileSystem(func.control());
|
||||
}
|
||||
|
||||
ShellControlFunction shellFunction();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
-fx-padding: 40 40 0 80;
|
||||
}
|
||||
|
||||
.root:portrait .prefs-box {
|
||||
.root:compact .prefs-box {
|
||||
-fx-padding: 20 20 20 20;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
-fx-padding: 0 0 0 1em;
|
||||
}
|
||||
|
||||
.root:portrait .prefs .prefs-container.options-comp > .options-comp {
|
||||
.root:compact .prefs .prefs-container.options-comp > .options-comp {
|
||||
-fx-padding: 0 0 0 0.2em;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
-fx-font-size: 1.5em;
|
||||
}
|
||||
|
||||
.root:portrait .prefs-container > .title-header {
|
||||
.root:compact .prefs-container > .title-header {
|
||||
-fx-padding: 1.5em 0 -0.5em 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user