From a26917b5002cda91529dd94dae71e558d4cd8824 Mon Sep 17 00:00:00 2001 From: crschnick Date: Sun, 4 Aug 2024 02:53:55 +0000 Subject: [PATCH] Small reliability fixes --- .../browser/file/BrowserQuickAccessContextMenu.java | 2 +- app/src/main/java/io/xpipe/app/core/AppTheme.java | 6 ++++++ .../xpipe/app/core/check/AppUserDirectoryCheck.java | 11 ++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/browser/file/BrowserQuickAccessContextMenu.java b/app/src/main/java/io/xpipe/app/browser/file/BrowserQuickAccessContextMenu.java index dc4f4b3f1..a1c0d3ba1 100644 --- a/app/src/main/java/io/xpipe/app/browser/file/BrowserQuickAccessContextMenu.java +++ b/app/src/main/java/io/xpipe/app/browser/file/BrowserQuickAccessContextMenu.java @@ -79,7 +79,7 @@ public class BrowserQuickAccessContextMenu extends ContextMenu { getItems().addAll(r.getItems()); // Prevent NPE in show() - if (getScene() == null) { + if (getScene() == null || anchor == null) { return; } show(anchor, Side.RIGHT, 0, 0); diff --git a/app/src/main/java/io/xpipe/app/core/AppTheme.java b/app/src/main/java/io/xpipe/app/core/AppTheme.java index 32b9cc0f8..05cdb6cb8 100644 --- a/app/src/main/java/io/xpipe/app/core/AppTheme.java +++ b/app/src/main/java/io/xpipe/app/core/AppTheme.java @@ -113,6 +113,9 @@ public class AppTheme { } }); }); + } catch (UnsupportedOperationException ex) { + // The platform preferences are sometimes not initialized yet + ErrorEvent.fromThrowable(ex).expected().omit().handle(); } catch (Throwable t) { ErrorEvent.fromThrowable(t).omit().handle(); } @@ -136,6 +139,9 @@ public class AppTheme { } else { AppPrefs.get().theme.setValue(Theme.getDefaultLightTheme()); } + } catch (UnsupportedOperationException ex) { + // The platform preferences are sometimes not initialized yet + ErrorEvent.fromThrowable(ex).expected().omit().handle(); } catch (Exception ex) { // The color scheme query can fail if the toolkit is not initialized properly AppPrefs.get().theme.setValue(Theme.getDefaultLightTheme()); diff --git a/app/src/main/java/io/xpipe/app/core/check/AppUserDirectoryCheck.java b/app/src/main/java/io/xpipe/app/core/check/AppUserDirectoryCheck.java index cf7684c91..acfa8ca33 100644 --- a/app/src/main/java/io/xpipe/app/core/check/AppUserDirectoryCheck.java +++ b/app/src/main/java/io/xpipe/app/core/check/AppUserDirectoryCheck.java @@ -15,14 +15,15 @@ public class AppUserDirectoryCheck { Files.createDirectories(dataDirectory); var testDirectory = dataDirectory.resolve("permissions_check"); Files.createDirectories(testDirectory); + if (!Files.exists(testDirectory)) { + throw new IOException("Directory creation in user home directory failed silently"); + } Files.delete(testDirectory); // if (true) throw new IOException(); } catch (IOException e) { - ErrorEvent.fromThrowable( - new IOException( - "Unable to access directory " + dataDirectory - + ". Please make sure that you have the appropriate permissions and no Antivirus program is blocking the access. " - + "In case you use cloud storage, verify that your cloud storage is working and you are logged in.")) + ErrorEvent.fromThrowable("Unable to access directory " + dataDirectory + + ". Please make sure that you have the appropriate permissions and no Antivirus program is blocking the access. " + + "In case you use cloud storage, verify that your cloud storage is working and you are logged in.", e) .term() .expected() .handle();