From 322acbe39caa0e2a70414f0c52d0152ab4ebe007 Mon Sep 17 00:00:00 2001 From: crschnick Date: Sun, 25 Feb 2024 16:38:32 +0000 Subject: [PATCH] Various fixes --- app/build.gradle | 1 + .../xpipe/app/browser/BrowserTransferModel.java | 4 ++++ .../io/xpipe/app/browser/FileSystemHelper.java | 4 +++- .../main/java/io/xpipe/app/prefs/AppPrefs.java | 16 ++++++++-------- .../io/xpipe/app/storage/StandardStorage.java | 6 +++--- .../java/io/xpipe/app/update/AppDownloads.java | 14 ++++---------- .../java/io/xpipe/app/update/AppInstaller.java | 4 ++-- .../java/io/xpipe/app/update/UpdateHandler.java | 2 +- 8 files changed, 26 insertions(+), 25 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 140a982aa..02667fe8a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -86,6 +86,7 @@ run { systemProperty 'io.xpipe.app.logLevel', "trace" systemProperty 'io.xpipe.app.fullVersion', rootProject.fullVersion systemProperty 'io.xpipe.app.showcase', 'true' + systemProperty 'io.xpipe.app.staging', isStage // systemProperty "io.xpipe.beacon.port", "21724" // systemProperty "io.xpipe.beacon.printMessages", "true" // systemProperty 'io.xpipe.app.debugPlatform', "true" diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserTransferModel.java b/app/src/main/java/io/xpipe/app/browser/BrowserTransferModel.java index 9d11312eb..93c134355 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserTransferModel.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserTransferModel.java @@ -42,6 +42,10 @@ public class BrowserTransferModel { BooleanProperty allDownloaded = new SimpleBooleanProperty(); private void cleanDirectory() { + if (!Files.isDirectory(TEMP)) { + return; + } + try (var ls = Files.list(TEMP)) { var list = ls.toList(); for (Path path : list) { diff --git a/app/src/main/java/io/xpipe/app/browser/FileSystemHelper.java b/app/src/main/java/io/xpipe/app/browser/FileSystemHelper.java index a6e7f0a3b..b7d618317 100644 --- a/app/src/main/java/io/xpipe/app/browser/FileSystemHelper.java +++ b/app/src/main/java/io/xpipe/app/browser/FileSystemHelper.java @@ -276,11 +276,13 @@ public class FileSystemHelper { for (FileSystem.FileEntry fileEntry : list) { flatFiles.put(fileEntry, FileNames.toUnix(FileNames.relativize(baseRelative, fileEntry.getPath()))); if (fileEntry.getKind() == FileKind.FILE) { - totalSize.addAndGet(fileEntry.getFileSystem().getFileSize(fileEntry.getPath())); + // This one is up-to-date and does not need to be recalculated + totalSize.addAndGet(fileEntry.getSize()); } } } else { flatFiles.put(source, FileNames.getFileName(source.getPath())); + // Recalculate as it could have been changed meanwhile totalSize.addAndGet(source.getFileSystem().getFileSize(source.getPath())); } diff --git a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java index f13e28f6f..76489a593 100644 --- a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java +++ b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java @@ -32,13 +32,13 @@ public class AppPrefs { private static final String DEVELOPER_MODE_PROP = "io.xpipe.app.developerMode"; private static AppPrefs INSTANCE; private final List> mapping = new ArrayList<>(); + final BooleanProperty dontAutomaticallyStartVmSshServer = - map(new SimpleBooleanProperty(false), "dontAutomaticallyStartVmSshServer", Boolean.class); + mapVaultSpecific(new SimpleBooleanProperty(false), "dontAutomaticallyStartVmSshServer", Boolean.class); final BooleanProperty dontAcceptNewHostKeys = - map(new SimpleBooleanProperty(false), "dontAcceptNewHostKeys", Boolean.class); + mapVaultSpecific(new SimpleBooleanProperty(false), "dontAcceptNewHostKeys", Boolean.class); final BooleanProperty performanceMode = map(new SimpleBooleanProperty(false), "performanceMode", Boolean.class); final BooleanProperty useBundledTools = map(new SimpleBooleanProperty(false), "useBundledTools", Boolean.class); - public final ObjectProperty theme = map(new SimpleObjectProperty<>(), "theme", AppTheme.Theme.class); final BooleanProperty useSystemFont = map(new SimpleBooleanProperty(true), "useSystemFont", Boolean.class); @@ -55,17 +55,17 @@ public class AppPrefs { final BooleanProperty clearTerminalOnInit = map(new SimpleBooleanProperty(true), "clearTerminalOnInit", Boolean.class); public final BooleanProperty disableCertutilUse = - map(new SimpleBooleanProperty(false), "disableCertutilUse", Boolean.class); + mapVaultSpecific(new SimpleBooleanProperty(false), "disableCertutilUse", Boolean.class); public final BooleanProperty useLocalFallbackShell = map(new SimpleBooleanProperty(false), "useLocalFallbackShell", Boolean.class); public final BooleanProperty disableTerminalRemotePasswordPreparation = - map(new SimpleBooleanProperty(false), "disableTerminalRemotePasswordPreparation", Boolean.class); + mapVaultSpecific(new SimpleBooleanProperty(false), "disableTerminalRemotePasswordPreparation", Boolean.class); public final Property alwaysConfirmElevation = - map(new SimpleObjectProperty<>(false), "alwaysConfirmElevation", Boolean.class); + mapVaultSpecific(new SimpleObjectProperty<>(false), "alwaysConfirmElevation", Boolean.class); public final BooleanProperty dontCachePasswords = - map(new SimpleBooleanProperty(false), "dontCachePasswords", Boolean.class); + mapVaultSpecific(new SimpleBooleanProperty(false), "dontCachePasswords", Boolean.class); public final BooleanProperty denyTempScriptCreation = - map(new SimpleBooleanProperty(false), "denyTempScriptCreation", Boolean.class); + mapVaultSpecific(new SimpleBooleanProperty(false), "denyTempScriptCreation", Boolean.class); final StringProperty passwordManagerCommand = map(new SimpleStringProperty(""), "passwordManagerCommand", String.class); final ObjectProperty startupBehaviour = diff --git a/app/src/main/java/io/xpipe/app/storage/StandardStorage.java b/app/src/main/java/io/xpipe/app/storage/StandardStorage.java index ffe67b39d..21741487b 100644 --- a/app/src/main/java/io/xpipe/app/storage/StandardStorage.java +++ b/app/src/main/java/io/xpipe/app/storage/StandardStorage.java @@ -143,7 +143,7 @@ public class StandardStorage extends DataStorage { // Show one exception if (exception.get() != null) { - ErrorEvent.fromThrowable(exception.get()).handle(); + ErrorEvent.fromThrowable(exception.get()).expected().handle(); } storeEntriesSet.forEach(dataStoreCategory -> { @@ -169,7 +169,7 @@ public class StandardStorage extends DataStorage { local.deleteFromDisk(); hasFixedLocal = false; } catch (IOException ex) { - ErrorEvent.fromThrowable(ex).terminal(true).build().handle(); + ErrorEvent.fromThrowable(ex).terminal(true).expected().build().handle(); } } } @@ -275,7 +275,7 @@ public class StandardStorage extends DataStorage { // Show one exception if (exception.get() != null) { - ErrorEvent.fromThrowable(exception.get()).handle(); + ErrorEvent.fromThrowable(exception.get()).expected().handle(); } deleteLeftovers(); diff --git a/app/src/main/java/io/xpipe/app/update/AppDownloads.java b/app/src/main/java/io/xpipe/app/update/AppDownloads.java index f7b5f3cf8..9d3e46e1c 100644 --- a/app/src/main/java/io/xpipe/app/update/AppDownloads.java +++ b/app/src/main/java/io/xpipe/app/update/AppDownloads.java @@ -111,19 +111,18 @@ public class AppDownloads { } } - public static Optional getLatestIncludingPreRelease() throws IOException { + public static Optional getTopReleaseIncludingPreRelease() throws IOException { var repo = getRepository(); return Optional.ofNullable(repo.listReleases().iterator().next()); } - public static Optional getLatestRelease() throws IOException { + public static Optional getMarkedLatestRelease() throws IOException { var repo = getRepository(); return Optional.ofNullable(repo.getLatestRelease()); } public static Optional getLatestSuitableRelease() throws IOException { - var preIncluding = getLatestIncludingPreRelease(); - + var preIncluding = getTopReleaseIncludingPreRelease(); // If we are currently running a prerelease, always return this as the suitable release! if (preIncluding.isPresent() && preIncluding.get().isPrerelease() @@ -131,12 +130,7 @@ public class AppDownloads { return preIncluding; } - // If this release is not a prerelease, just return it to prevent querying another release - if (preIncluding.isPresent() && !preIncluding.get().isPrerelease()) { - return preIncluding; - } - - return getLatestRelease(); + return getMarkedLatestRelease(); } public static Optional getRelease(String version, boolean omitErrors) { diff --git a/app/src/main/java/io/xpipe/app/update/AppInstaller.java b/app/src/main/java/io/xpipe/app/update/AppInstaller.java index 25077317f..a845035b6 100644 --- a/app/src/main/java/io/xpipe/app/update/AppInstaller.java +++ b/app/src/main/java/io/xpipe/app/update/AppInstaller.java @@ -74,11 +74,11 @@ public class AppInstaller { String.format( """ cd /D "%%HOMEDRIVE%%%%HOMEPATH%%" - start "" /wait msiexec /i "%s" /lv "%s" /qb + start "" /wait msiexec /i "%s" /lv "%s" /qr start "" "%s" """, file, logFile, exec)); - shellProcessControl.executeSimpleCommand("start \"\" /min cmd /c \"" + script + "\""); + shellProcessControl.executeSimpleCommand("start \"XPipe Updater\" /min cmd /c \"" + script + "\""); } @Override diff --git a/app/src/main/java/io/xpipe/app/update/UpdateHandler.java b/app/src/main/java/io/xpipe/app/update/UpdateHandler.java index c8cba8b65..94b0257ee 100644 --- a/app/src/main/java/io/xpipe/app/update/UpdateHandler.java +++ b/app/src/main/java/io/xpipe/app/update/UpdateHandler.java @@ -231,7 +231,7 @@ public abstract class UpdateHandler { // In case we perform any operations such as opening a terminal // give it some time to open while this process is still alive // Otherwise it might quit because the parent process is dead already - ThreadHelper.sleep(2000); + ThreadHelper.sleep(100); } catch (Throwable ex) { ex.printStackTrace(); }