Bladeren bron

[Bug] [Task-plugin] ShellTask add the parentfolder exist check and create if not exit (#8526)

* check the parent dir exist and create it

* fix lint

Co-authored-by: ywang46 <ywang46@paypal.com>
Yao WANG 3 jaren geleden
bovenliggende
commit
dd1397aaed

+ 5 - 1
dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java

@@ -124,7 +124,8 @@ public class ShellTask extends AbstractTaskExecutor {
                 taskExecutionContext.getExecutePath(),
                 taskExecutionContext.getTaskAppId(), OSUtils.isWindows() ? "bat" : "sh");
 
-        Path path = new File(fileName).toPath();
+        File file = new File(fileName);
+        Path path = file.toPath();
 
         if (Files.exists(path)) {
             return fileName;
@@ -143,6 +144,9 @@ public class ShellTask extends AbstractTaskExecutor {
         if (OSUtils.isWindows()) {
             Files.createFile(path);
         } else {
+            if (!file.getParentFile().exists()){
+                file.getParentFile().mkdirs();
+            }
             Files.createFile(path, attr);
         }