From 4a351f8598a35f71bd69ccbef7fb451247a9f4f0 Mon Sep 17 00:00:00 2001 From: crschnick Date: Fri, 17 May 2024 18:44:49 +0000 Subject: [PATCH] Improve handling of directories when permissions are missing --- .../java/io/xpipe/app/browser/file/FileSystemHelper.java | 8 ++++---- .../java/io/xpipe/app/browser/fs/OpenFileSystemModel.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/browser/file/FileSystemHelper.java b/app/src/main/java/io/xpipe/app/browser/file/FileSystemHelper.java index 26a5a8df..fd408e2e 100644 --- a/app/src/main/java/io/xpipe/app/browser/file/FileSystemHelper.java +++ b/app/src/main/java/io/xpipe/app/browser/file/FileSystemHelper.java @@ -66,7 +66,7 @@ public class FileSystemHelper { } } - public static String resolveDirectoryPath(OpenFileSystemModel model, String path) throws Exception { + public static String resolveDirectoryPath(OpenFileSystemModel model, String path, boolean allowRewrite) throws Exception { if (path == null) { return null; } @@ -90,14 +90,14 @@ public class FileSystemHelper { throw new IllegalArgumentException(String.format("Directory %s is not absolute", resolved)); } - if (model.getFileSystem().fileExists(path)) { + if (allowRewrite && model.getFileSystem().fileExists(path)) { return FileNames.toDirectory(FileNames.getParent(path)); } return FileNames.toDirectory(resolved); } - public static void validateDirectoryPath(OpenFileSystemModel model, String path) throws Exception { + public static void validateDirectoryPath(OpenFileSystemModel model, String path, boolean verifyExists) throws Exception { if (path == null) { return; } @@ -111,7 +111,7 @@ public class FileSystemHelper { return; } - if (!model.getFileSystem().directoryExists(path)) { + if (verifyExists && !model.getFileSystem().directoryExists(path)) { throw ErrorEvent.expected(new IllegalArgumentException(String.format("Directory %s does not exist", path))); } diff --git a/app/src/main/java/io/xpipe/app/browser/fs/OpenFileSystemModel.java b/app/src/main/java/io/xpipe/app/browser/fs/OpenFileSystemModel.java index 9761655e..070c3873 100644 --- a/app/src/main/java/io/xpipe/app/browser/fs/OpenFileSystemModel.java +++ b/app/src/main/java/io/xpipe/app/browser/fs/OpenFileSystemModel.java @@ -200,7 +200,7 @@ public final class OpenFileSystemModel extends BrowserSessionTab cdSyncOrRetry(s, false)); } - public Optional cdSyncOrRetry(String path, boolean allowCommands) { + public Optional cdSyncOrRetry(String path, boolean customInput) { if (Objects.equals(path, currentPath.get())) { return Optional.empty(); } @@ -233,7 +233,7 @@ public final class OpenFileSystemModel extends BrowserSessionTab