Browse Source

[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>
3.0.0/version-upgrade
Yao WANG 3 years ago committed by GitHub
parent
commit
dd1397aaed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java

6
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);
}

Loading…
Cancel
Save