mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-02 04:08:31 +08:00
Fix create parent directory will cause FileAlreadyExistsException (#15576)
Co-authored-by: Rick Cheng <rickchengx@gmail.com>
This commit is contained in:
parent
69676b445c
commit
4541e74e53
@ -35,6 +35,7 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.FileAlreadyExistsException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.attribute.PosixFilePermission;
|
import java.nio.file.attribute.PosixFilePermission;
|
||||||
@ -287,8 +288,13 @@ public class FileUtils {
|
|||||||
createDirectoryWith755(parent);
|
createDirectoryWith755(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
Files.createDirectory(path);
|
try {
|
||||||
Files.setPosixFilePermissions(path, PERMISSION_755);
|
Files.createDirectory(path);
|
||||||
|
Files.setPosixFilePermissions(path, PERMISSION_755);
|
||||||
|
} catch (FileAlreadyExistsException fileAlreadyExistsException) {
|
||||||
|
// Catch the FileAlreadyExistsException here to avoid create the same parent directory in parallel
|
||||||
|
log.debug("The directory: {} already exists", path);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user