From 619d8adf560bd5b2d4a655ecd499cba94c02826c Mon Sep 17 00:00:00 2001 From: Benoit DUMONT Date: Sat, 4 Nov 2023 08:21:01 +0100 Subject: [PATCH] CleanFolder now report unauthorised even of folder does not exist. --- .../filemanagement/ExecuteFilemanagementAction.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/cerberus/robot/extension/filemanagement/ExecuteFilemanagementAction.java b/src/main/java/org/cerberus/robot/extension/filemanagement/ExecuteFilemanagementAction.java index 271f85b..6459e18 100644 --- a/src/main/java/org/cerberus/robot/extension/filemanagement/ExecuteFilemanagementAction.java +++ b/src/main/java/org/cerberus/robot/extension/filemanagement/ExecuteFilemanagementAction.java @@ -295,14 +295,15 @@ private JSONObject clean_folder(String filenamecomplete, String authorisedFolder filename = ""; } - if (!pathDir.exists()) { - actionResult.put("message", "Path '" + pathDir.getAbsolutePath() + "' does not exist !! We consider it as empty/cleaned already..."); - actionResult.put("status", "OK"); - actionResult.put("code", 200); - } else if (!check_authorisation(pathDir, authorisedFolderScope)) { - actionResult.put("message", "Path '" + pathDir.getAbsolutePath() + "' is not authorised !! The path '" + pathDir.toPath().toRealPath().toString() + File.separator + "' is not inside '" + authorisedFolderScope + "'."); + if (!check_authorisation(pathDir, authorisedFolderScope)) { + actionResult.put("message", "Path '" + pathDir.getAbsolutePath() + "' is not authorised !! It is not inside '" + authorisedFolderScope + "'."); actionResult.put("status", "Failed"); actionResult.put("code", 403); + } else if (!pathDir.exists()) { + pathDir.mkdirs(); + actionResult.put("message", "Path '" + pathDir.getAbsolutePath() + "' does not exist !! Folder created and cleaned..."); + actionResult.put("status", "OK"); + actionResult.put("code", 200); } else { // Get all files. File[] rawfiles;