Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
crschnick committed May 10, 2024
1 parent 3363ad9 commit 7507f66
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public OpenFileSystemCache(OpenFileSystemModel model) throws Exception {

ShellControl sc = model.getFileSystem().getShell().get();
ShellDialect d = sc.getShellDialect();
username = d.printUsernameCommand(sc).readStdoutOrThrow();
// If there is no id command, we should still be fine with just assuming root
username = d.printUsernameCommand(sc).readStdoutIfPossible().orElse("root");
}

public boolean isRoot() {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/io/xpipe/app/core/AppPreloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public void start(Stage primaryStage) {
ModuleLayer.boot().findModule("javafx.graphics").orElseThrow(), "com.sun.glass.ui.Application");
var m = c.getDeclaredMethod("setName", String.class);
m.invoke(c.getMethod("GetApplication").invoke(null), "XPipe");
TrackEvent.info("Application preloaded launched");
TrackEvent.info("Application preloader run");
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.xpipe.app.fxcomps.impl;

import atlantafx.base.theme.Styles;
import io.xpipe.app.browser.session.BrowserChooserComp;
import io.xpipe.app.comp.base.ButtonComp;
import io.xpipe.app.core.AppI18n;
Expand All @@ -15,17 +16,13 @@
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.core.store.FileNames;
import io.xpipe.core.store.FileSystemStore;

import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.Alert;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;

import atlantafx.base.theme.Styles;
import org.kordamp.ikonli.javafx.FontIcon;

import java.nio.file.Files;
Expand Down Expand Up @@ -84,38 +81,26 @@ public CompStructure<HBox> createBase() {
.styleClass(Styles.CENTER_PILL)
.grow(false, true);

var canGitShare = Bindings.createBooleanBinding(
() -> {
if (!AppPrefs.get().enableGitStorage().get()
|| filePath.getValue() == null
|| ContextualFileReference.of(filePath.getValue()).isInDataDirectory()) {
return false;
}

return true;
},
filePath,
AppPrefs.get().enableGitStorage());
var gitShareButton = new ButtonComp(null, new FontIcon("mdi2g-git"), () -> {
if (!AppPrefs.get().enableGitStorage().get()) {
AppLayoutModel.get().selectSettings();
AppPrefs.get().selectCategory("synchronization");
AppPrefs.get().selectCategory("sync");
return;
}

if (filePath.getValue() == null
|| ContextualFileReference.of(filePath.getValue()).isInDataDirectory()) {
var currentPath = filePath.getValue();
if (currentPath == null || currentPath.isBlank()) {
return;
}

if (filePath.getValue() == null || filePath.getValue().isBlank() || !canGitShare.get()) {
if (ContextualFileReference.of(currentPath).isInDataDirectory()) {
return;
}

try {
var data = DataStorage.get().getDataDir();
var f = data.resolve(FileNames.getFileName(filePath.getValue().trim()));
var source = Path.of(filePath.getValue().trim());
var f = data.resolve(FileNames.getFileName(currentPath.trim()));
var source = Path.of(currentPath.trim());
if (Files.exists(source)) {
var shouldCopy = AppWindowHelper.showBlockingAlert(alert -> {
alert.setTitle(AppI18n.get("confirmGitShareTitle"));
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/io/xpipe/app/util/JsonConfigHelper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.xpipe.app.util;

import com.fasterxml.jackson.core.JsonParseException;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.core.util.JacksonMapper;

Expand All @@ -26,8 +27,10 @@ public static JsonNode readRaw(Path in) {
var read = o.readTree(Files.readAllBytes(in));
return read;
}
} catch (JsonParseException e) {
ErrorEvent.fromThrowable("Unable to parse file " + in, e).expected().build().handle();
} catch (IOException e) {
ErrorEvent.fromThrowable(e).build().handle();
ErrorEvent.fromThrowable("Unable to parse file " + in, e).build().handle();
}
return JsonNodeFactory.instance.missingNode();
}
Expand Down Expand Up @@ -57,7 +60,7 @@ public static void writeConfig(Path out, JsonNode node) {
var newContent = writer.toString();
Files.writeString(out, newContent);
} catch (IOException e) {
ErrorEvent.fromThrowable(e).build().handle();
ErrorEvent.fromThrowable("Unable to write file " + out, e).build().handle();
}
}
}
5 changes: 5 additions & 0 deletions dist/changelogs/9.2_incremental.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ The file browser has been reworked to support many new keyboard shortcuts and th
- Fix a corrupted PATH leading to cmd or powershell not being able to be started
- Fix headless system error message not being printed when application failed to start up
- Fix offline licenses not properly applying
- Fix WMClass not being properly set on Linux
- Fix file browser files being dragged into finder creating raw clipboard file
- Fix SSH gateway not updating when choosing key file on another host
- Fix file browser failing to connect if target system did not have id command available
- Fix git share file button not jumping to correct settings menu

0 comments on commit 7507f66

Please sign in to comment.