From 9ff38247e5df04851866677fc8e1b878468ee81c Mon Sep 17 00:00:00 2001 From: Yannick Marcon Date: Sun, 12 Jan 2025 18:48:30 +0100 Subject: [PATCH] fix: file not found when not readable or parent not readable (#3985) --- .../main/java/org/obiba/opal/web/FilesResource.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/opal-core-ws/src/main/java/org/obiba/opal/web/FilesResource.java b/opal-core-ws/src/main/java/org/obiba/opal/web/FilesResource.java index 30802db231..8cbb0c69b0 100644 --- a/opal-core-ws/src/main/java/org/obiba/opal/web/FilesResource.java +++ b/opal-core-ws/src/main/java/org/obiba/opal/web/FilesResource.java @@ -97,9 +97,13 @@ public Response getFileSystemRootDetails() throws IOException { @NoAuthorization public Response getFileDetails(@PathParam("path") String path) throws IOException { FileObject file = resolveFileInFileSystem(path); - return file.exists() - ? file.getType() == FileType.FILE ? getFileDetails(file) : getFolderDetails(file) - : getPathNotExistResponse("/" + path); + if (!file.getParent().isReadable() || !file.exists()) { + return getPathNotExistResponse("/" + path); + } + if (file.getType() == FileType.FILE) { + return file.isReadable() ? getFileDetails(file) : getPathNotExistResponse("/" + path); + } + return getFolderDetails(file); } @GET