From bd2acc6574373ae8aa09592ed63b189ea8d793d3 Mon Sep 17 00:00:00 2001 From: crschnick Date: Tue, 16 Jan 2024 13:05:21 +0000 Subject: [PATCH] Various small fixes --- .../app/comp/store/StoreEntryWrapper.java | 5 +++++ .../xpipe/app/issue/SentryErrorHandler.java | 1 + .../io/xpipe/app/storage/DataStorage.java | 10 +++------ .../app/storage/ImpersistentStorage.java | 2 +- .../io/xpipe/app/storage/StandardStorage.java | 12 ++++++++-- .../java/io/xpipe/app/util/PlatformState.java | 6 ++--- dist/changelogs/1.7.15.md | 2 +- dist/jpackage.gradle | 22 ++++++++++--------- .../xpipe/ext/base/SelfReferentialStore.java | 4 +++- 9 files changed, 39 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/comp/store/StoreEntryWrapper.java b/app/src/main/java/io/xpipe/app/comp/store/StoreEntryWrapper.java index 3c70fe3a0..0446b0d87 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StoreEntryWrapper.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StoreEntryWrapper.java @@ -98,6 +98,11 @@ public class StoreEntryWrapper { } public void update() { + // We are probably in shutdown then + if (StoreViewState.get() == null) { + return; + } + // Avoid reupdating name when changed from the name property! if (!entry.getName().equals(name.getValue())) { name.setValue(entry.getName()); diff --git a/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java b/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java index 3074086d2..cc0bd8d54 100644 --- a/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java +++ b/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java @@ -181,6 +181,7 @@ public class SentryErrorHandler implements ErrorHandler { s.setTag("omitted", Boolean.toString(ee.isOmitted())); s.setTag("diagnostics", Boolean.toString(ee.isShouldSendDiagnostics())); s.setTag("logs", Boolean.toString(ee.isShouldSendDiagnostics() && !ee.getAttachments().isEmpty())); + s.setTag("inShutdown", Boolean.toString(OperationMode.isInShutdown())); var exMessage = ee.getThrowable() != null ? ee.getThrowable().getMessage() : null; if (ee.getDescription() != null && !ee.getDescription().equals(exMessage) && ee.isShouldSendDiagnostics()) { diff --git a/app/src/main/java/io/xpipe/app/storage/DataStorage.java b/app/src/main/java/io/xpipe/app/storage/DataStorage.java index a37225a11..7d70f27c3 100644 --- a/app/src/main/java/io/xpipe/app/storage/DataStorage.java +++ b/app/src/main/java/io/xpipe/app/storage/DataStorage.java @@ -38,9 +38,6 @@ public abstract class DataStorage { @Getter protected boolean loaded; - @Getter - protected boolean disposed; - @Getter protected final List storeCategories; @@ -115,8 +112,7 @@ public abstract class DataStorage { private synchronized void dispose() { onReset(); - save(); - disposed = true; + save(true); } protected void onReset() {} @@ -156,11 +152,11 @@ public abstract class DataStorage { } ThreadHelper.runAsync(() -> { - save(); + save(false); }); } - public abstract void save(); + public abstract void save(boolean dispose); public abstract boolean supportsSharing(); public boolean shouldShare(DataStoreCategory entry) { diff --git a/app/src/main/java/io/xpipe/app/storage/ImpersistentStorage.java b/app/src/main/java/io/xpipe/app/storage/ImpersistentStorage.java index 29ed7a100..99dc448e2 100644 --- a/app/src/main/java/io/xpipe/app/storage/ImpersistentStorage.java +++ b/app/src/main/java/io/xpipe/app/storage/ImpersistentStorage.java @@ -18,7 +18,7 @@ public class ImpersistentStorage extends DataStorage { } @Override - public void save() { + public void save(boolean dispose) { var storesDir = getStoresDir(); TrackEvent.info("Storage persistence is disabled. Deleting storage contents ..."); 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 dcf043d9d..f358e33d8 100644 --- a/app/src/main/java/io/xpipe/app/storage/StandardStorage.java +++ b/app/src/main/java/io/xpipe/app/storage/StandardStorage.java @@ -25,6 +25,9 @@ public class StandardStorage extends DataStorage { @Getter private final GitStorageHandler gitStorageHandler; + @Getter + private boolean disposed; + StandardStorage() { this.gitStorageHandler = GitStorageHandler.getInstance(); this.gitStorageHandler.init(dir); @@ -119,10 +122,12 @@ public class StandardStorage extends DataStorage { var storesDir = getStoresDir(); var categoriesDir = getCategoriesDir(); + var dataDir = getDataDir(); try { FileUtils.forceMkdir(storesDir.toFile()); FileUtils.forceMkdir(categoriesDir.toFile()); + FileUtils.forceMkdir(dataDir.toFile()); } catch (Exception e) { ErrorEvent.fromThrowable(e).terminal(true).build().handle(); } @@ -292,7 +297,7 @@ public class StandardStorage extends DataStorage { entry.dirty = true; entry.setStoreNode(DataStorageWriter.storeToNode(entry.getStore())); }); - save(); + save(false); } deleteLeftovers(); @@ -302,7 +307,7 @@ public class StandardStorage extends DataStorage { this.gitStorageHandler.afterStorageLoad(); } - public void save() { + public void save(boolean dispose) { if (!loaded || disposed) { return; } @@ -363,6 +368,9 @@ public class StandardStorage extends DataStorage { deleteLeftovers(); gitStorageHandler.afterStorageSave(); + if (dispose) { + disposed = true; + } busyIo.unlock(); } diff --git a/app/src/main/java/io/xpipe/app/util/PlatformState.java b/app/src/main/java/io/xpipe/app/util/PlatformState.java index 1c6ce42c9..c03b8734b 100644 --- a/app/src/main/java/io/xpipe/app/util/PlatformState.java +++ b/app/src/main/java/io/xpipe/app/util/PlatformState.java @@ -27,10 +27,10 @@ public enum PlatformState { public static void teardown() { PlatformThread.runLaterIfNeededBlocking(() -> { - // Fix to preserve clipboard contents after shutdown - var string = Clipboard.getSystemClipboard().getString(); - var s = new StringSelection(string); try { + // Fix to preserve clipboard contents after shutdown + var string = Clipboard.getSystemClipboard().getString(); + var s = new StringSelection(string); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(s, s); } catch (IllegalStateException ignored) { } diff --git a/dist/changelogs/1.7.15.md b/dist/changelogs/1.7.15.md index 4bc7a684a..aeb6beab5 100644 --- a/dist/changelogs/1.7.15.md +++ b/dist/changelogs/1.7.15.md @@ -3,7 +3,7 @@ - Add support to create customized SSH connections using arbitrary options. This can be done using the SSH config format but without having to create an actual file. - Unify all SSH connection types to support the same functionality. - I.e. you can now use SSH config connections to set up SSH tunnels as well. + I.e. they all now support host key and identity file fixes plus can be used as SSH tunnels. - Properly detect when an active connection has unexpectedly reset during a file browser session. It will now be automatically restarted when any action is performed and fails. - Rework connection creation menu layout to give a better overview diff --git a/dist/jpackage.gradle b/dist/jpackage.gradle index 87ef33661..c4df627ed 100644 --- a/dist/jpackage.gradle +++ b/dist/jpackage.gradle @@ -25,7 +25,7 @@ application { } def appDependencies = project(':app').configurations.findByName('runtimeClasspath').getFiles().stream() - .filter(f -> !f.name.startsWith('javafx')) // Remove JavaFX dependencies + .filter(f -> !fullVersion || !f.name.startsWith('javafx')) // Remove JavaFX dependencies .collect(Collectors.toMap(f -> f.toPath().getFileName().toString(), f -> f, (f1, f2) -> f1)) .values() def appModuleNames = ['app'] @@ -53,16 +53,18 @@ jlink { // '--strip-native-commands' ] - def currentOS = DefaultNativePlatform.currentOperatingSystem; - def platform = null - if (currentOS.isWindows()) { - platform = 'windows' - } else if (currentOS.isLinux()) { - platform = 'linux' - } else if (currentOS.isMacOsX()) { - platform = 'osx' + if (fullVersion) { + def currentOS = DefaultNativePlatform.currentOperatingSystem; + def platform = null + if (currentOS.isWindows()) { + platform = 'windows' + } else if (currentOS.isLinux()) { + platform = 'linux' + } else if (currentOS.isMacOsX()) { + platform = 'osx' + } + addExtraModulePath(layout.projectDirectory.dir("javafx/${platform}/${arch}").toString()) } - addExtraModulePath(layout.projectDirectory.dir("javafx/${platform}/${arch}").toString()) launcher { moduleName = 'io.xpipe.app' diff --git a/ext/base/src/main/java/io/xpipe/ext/base/SelfReferentialStore.java b/ext/base/src/main/java/io/xpipe/ext/base/SelfReferentialStore.java index 32ecedf21..3c5386092 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/SelfReferentialStore.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/SelfReferentialStore.java @@ -9,7 +9,9 @@ import java.util.UUID; public interface SelfReferentialStore extends DataStore { default DataStoreEntry getSelfEntry() { - return DataStorage.get().getStoreEntries().stream().filter(dataStoreEntry -> dataStoreEntry.getStore() == this).findFirst().orElseGet(() -> { + return DataStorage.get().getStoreEntryIfPresent(this).or(() -> { + return DataStorage.get().getStoreEntryInProgressIfPresent(this); + }).orElseGet(() -> { return DataStoreEntry.createNew(UUID.randomUUID(),DataStorage.DEFAULT_CATEGORY_UUID, "Invalid", this); }); }