Update readme

This commit is contained in:
crschnick
2023-02-28 14:22:49 +00:00
parent 1bde4c8909
commit d5a7e2fb64
17 changed files with 91 additions and 47 deletions

View File

@@ -39,7 +39,8 @@ public class OpenFileSystemComp extends SimpleComp {
var path = new SimpleStringProperty(model.getCurrentPath().get());
var pathBar = new TextFieldComp(path, true).createRegion();
path.addListener((observable, oldValue, newValue) -> {
model.cd(newValue);
var changed = model.cd(newValue);
changed.ifPresent(path::set);
});
model.getCurrentPath().addListener((observable, oldValue, newValue) -> {
path.set(newValue);

View File

@@ -6,6 +6,7 @@ import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.util.BusyProperty;
import io.xpipe.app.util.TerminalHelper;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.impl.LocalStore;
import io.xpipe.core.store.ConnectionFileSystem;
import io.xpipe.core.store.FileSystem;
import io.xpipe.core.store.FileSystemStore;
@@ -18,6 +19,7 @@ import java.nio.file.Path;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@Getter
@@ -51,25 +53,27 @@ final class OpenFileSystemModel {
return new FileSystem.FileEntry(fileSystem, currentPath.get(), Instant.now(), true, false, false, 0);
}
public void cd(String path) {
public Optional<String> cd(String path) {
var newPath = FileSystemHelper.normalizeDirectoryPath(this, path);
if (!path.equals(newPath)) {
return Optional.of(newPath);
}
ThreadHelper.runFailableAsync(() -> {
try (var ignored = new BusyProperty(busy)) {
cdSync(path);
}
});
return Optional.empty();
}
private boolean cdSync(String path) {
private void cdSync(String path) {
path = FileSystemHelper.normalizeDirectoryPath(this, path);
if (!navigateToSync(path)) {
return false;
}
navigateToSync(path);
filter.setValue(null);
currentPath.set(path);
history.cd(path);
return true;
}
private boolean navigateToSync(String dir) {
@@ -85,6 +89,7 @@ final class OpenFileSystemModel {
fileList.setAll(newList);
return true;
} catch (Exception e) {
fileList.setAll(List.of());
ErrorEvent.fromThrowable(e).handle();
return false;
}
@@ -171,7 +176,7 @@ final class OpenFileSystemModel {
fs.open();
this.fileSystem = fs;
var current = fs instanceof ConnectionFileSystem connectionFileSystem
var current = !(fileSystem instanceof LocalStore) && fs instanceof ConnectionFileSystem connectionFileSystem
? connectionFileSystem
.getShellProcessControl()
.executeStringSimpleCommand(connectionFileSystem

View File

@@ -66,7 +66,8 @@ public class AppGreetings {
}
public static void showIfNeeded() {
if (!AppProperties.get().isImage()) {
//TODO
if (!AppProperties.get().isImage() || true) {
return;
}

View File

@@ -66,7 +66,11 @@ public class SentryErrorHandler {
s.setTag("terminal", Boolean.toString(ee.isTerminal()));
s.setTag("omitted", Boolean.toString(ee.isOmitted()));
ee.getTrackEvents().forEach(t -> s.addBreadcrumb(toBreadcrumb(t)));
/*
TODO: Ignore breadcrumbs for now
*/
// ee.getTrackEvents().forEach(t -> s.addBreadcrumb(toBreadcrumb(t)));
if (ee.getThrowable() != null) {
if (ee.getDescription() != null

View File

@@ -5,7 +5,6 @@ import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.core.impl.LocalStore;
import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ShellProcessControl;
import io.xpipe.core.store.ShellStore;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -38,7 +37,7 @@ public abstract class ExternalApplicationType implements PrefsChoiceValue {
}
protected Optional<Path> getApplicationPath() {
try (ShellProcessControl pc = ShellStore.createLocal().create().start()) {
try (ShellProcessControl pc = LocalStore.getShell().start()) {
try (var c = pc.command(String.format(
"/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister "
+ "-dump | grep -o \"/.*%s.app\" | grep -v -E \"Caches|TimeMachine|Temporary|/Volumes/%s\" | uniq",

View File

@@ -2,7 +2,6 @@ package io.xpipe.app.util;
import io.xpipe.core.impl.LocalStore;
import io.xpipe.core.process.OsType;
import io.xpipe.core.store.ShellStore;
import io.xpipe.core.util.XPipeInstallation;
import java.nio.file.Files;
@@ -21,7 +20,7 @@ public class DesktopShortcuts {
%%PWS%% -Command "$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut('%%SHORTCUT%%'); $S.IconLocation='%s'; $S.TargetPath = '%%TARGET%%'; $S.Save()"
""",
target, name, icon.toString());
ShellStore.createLocal().create().executeSimpleCommand(content);
LocalStore.getShell().executeSimpleCommand(content);
}
private static void createLinuxShortcut(String target, String name) throws Exception {

View File

@@ -3,9 +3,9 @@ package io.xpipe.app.util;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.core.impl.FileNames;
import io.xpipe.core.impl.LocalStore;
import io.xpipe.core.process.OsType;
import io.xpipe.core.store.FileSystem;
import io.xpipe.core.store.ShellStore;
import org.apache.commons.io.FilenameUtils;
import java.nio.file.Path;
@@ -65,7 +65,7 @@ public class FileOpener {
}
public static void openInDefaultApplication(String file) {
try (var pc = ShellStore.createLocal().create().start()) {
try (var pc = LocalStore.getShell().start()) {
if (pc.getOsType().equals(OsType.WINDOWS)) {
pc.executeSimpleCommand("\"" + file + "\"");
} else if (pc.getOsType().equals(OsType.LINUX)) {

View File

@@ -2,7 +2,7 @@ package io.xpipe.app.util;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppWindowHelper;
import io.xpipe.core.store.ShellStore;
import io.xpipe.core.impl.LocalStore;
import javafx.application.Platform;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.scene.control.Alert;
@@ -14,7 +14,7 @@ public class MacOsPermissions {
public static boolean waitForAccessibilityPermissions() throws Exception {
AtomicReference<Alert> alert = new AtomicReference<>();
var state = new SimpleBooleanProperty(true);
try (var pc = ShellStore.createLocal().create().start()) {
try (var pc = LocalStore.getShell().start()) {
while (state.get()) {
var success = pc.executeBooleanSimpleCommand(
"osascript -e 'tell application \"System Events\" to keystroke \"t\"'");

View File

@@ -2,11 +2,11 @@ package io.xpipe.app.util;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.core.impl.FileNames;
import io.xpipe.core.impl.LocalStore;
import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ShellProcessControl;
import io.xpipe.core.process.ShellDialect;
import io.xpipe.core.process.ShellDialects;
import io.xpipe.core.store.ShellStore;
import io.xpipe.core.process.ShellProcessControl;
import io.xpipe.core.util.SecretValue;
import lombok.SneakyThrows;
@@ -42,7 +42,7 @@ public class ScriptHelper {
@SneakyThrows
public static String createLocalExecScript(String content) {
try (var l = ShellStore.createLocal().create().start()) {
try (var l = LocalStore.getShell().start()) {
return createExecScript(l, content);
}
}
@@ -167,6 +167,19 @@ public class ScriptHelper {
return t.getInitFileOpenCommand(initFile);
}
@SneakyThrows
public static String getExecScriptFile(ShellProcessControl processControl) {
return getExecScriptFile(processControl, processControl.getShellDialect().getScriptFileEnding());
}
@SneakyThrows
public static String getExecScriptFile(ShellProcessControl processControl, String fileEnding) {
var fileName = "exec-" + getScriptId();
var temp = processControl.getTemporaryDirectory();
var file = FileNames.join(temp, fileName + "." + fileEnding);
return file;
}
@SneakyThrows
public static String createExecScript(ShellProcessControl processControl, String content) {
var fileName = "exec-" + getScriptId();