mirror of
https://github.com/xpipe-io/xpipe.git
synced 2025-04-18 10:13:38 +00:00
Improve handling of directories when permissions are missing
This commit is contained in:
parent
a1575f4042
commit
4a351f8598
2 changed files with 8 additions and 8 deletions
|
@ -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)));
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ public final class OpenFileSystemModel extends BrowserSessionTab<FileSystemStore
|
|||
cdSyncOrRetry(path, false).ifPresent(s -> cdSyncOrRetry(s, false));
|
||||
}
|
||||
|
||||
public Optional<String> cdSyncOrRetry(String path, boolean allowCommands) {
|
||||
public Optional<String> cdSyncOrRetry(String path, boolean customInput) {
|
||||
if (Objects.equals(path, currentPath.get())) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ public final class OpenFileSystemModel extends BrowserSessionTab<FileSystemStore
|
|||
}
|
||||
|
||||
// Handle commands typed into navigation bar
|
||||
if (allowCommands
|
||||
if (customInput
|
||||
&& evaluatedPath != null
|
||||
&& !evaluatedPath.isBlank()
|
||||
&& !FileNames.isAbsolute(evaluatedPath)
|
||||
|
@ -263,7 +263,7 @@ public final class OpenFileSystemModel extends BrowserSessionTab<FileSystemStore
|
|||
// Evaluate optional links
|
||||
String resolvedPath;
|
||||
try {
|
||||
resolvedPath = FileSystemHelper.resolveDirectoryPath(this, evaluatedPath);
|
||||
resolvedPath = FileSystemHelper.resolveDirectoryPath(this, evaluatedPath, customInput);
|
||||
} catch (Exception ex) {
|
||||
ErrorEvent.fromThrowable(ex).handle();
|
||||
return Optional.ofNullable(currentPath.get());
|
||||
|
@ -274,7 +274,7 @@ public final class OpenFileSystemModel extends BrowserSessionTab<FileSystemStore
|
|||
}
|
||||
|
||||
try {
|
||||
FileSystemHelper.validateDirectoryPath(this, resolvedPath);
|
||||
FileSystemHelper.validateDirectoryPath(this, resolvedPath, customInput);
|
||||
cdSyncWithoutCheck(path);
|
||||
} catch (Exception ex) {
|
||||
ErrorEvent.fromThrowable(ex).handle();
|
||||
|
|
Loading…
Add table
Reference in a new issue