[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>
This commit is contained in:
Yao WANG 2022-02-24 17:36:54 +08:00 committed by GitHub
parent 3025f67d37
commit dd1397aaed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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