Skip to content

Commit fc379be

Browse files
committed
Switch to use user.home for all temp directory and added prefix to avoid filling up /tmp.
1 parent 00f2904 commit fc379be

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/main/java/com/oracle/weblogicx/imagebuilder/cli/menu/CreateImage.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ public CommandResponse call() throws Exception {
6868

6969
List<String> cmdBuilder = getInitialBuildCmd();
7070
// create a tmp directory for user.
71-
tmpDir = Files.createTempDirectory(null);
71+
// using user home as base to avoid running out of space in tmp
72+
tmpDir = Files.createTempDirectory(Paths.get(System.getProperty("user.home")),
73+
"wlsimgbuilder_temp");
7274
String tmpDirPath = tmpDir.toAbsolutePath().toString();
7375
logger.info("tmp directory used for build context: " + tmpDirPath);
7476
Path tmpPatchesDir = Files.createDirectory(Paths.get(tmpDirPath, "patches"));
@@ -80,7 +82,8 @@ public CommandResponse call() throws Exception {
8082
if (fromImage != null && !fromImage.isEmpty()) {
8183
cmdBuilder.add(BUILD_ARG);
8284

83-
tmpDir2 = Files.createTempDirectory(Paths.get(System.getProperty("user.home")), null);
85+
tmpDir2 = Files.createTempDirectory(Paths.get(System.getProperty("user.home")),
86+
"wlsimgbuilder_temp");
8487
logger.info("tmp directory in user.home for docker run: " + tmpDir2);
8588

8689
Utils.copyResourceAsFile("/probe-env/test-create-env.sh",

src/main/java/com/oracle/weblogicx/imagebuilder/util/Utils.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ public static void deleteFilesRecursively(Path tmpDir) throws IOException {
323323
.map(Path::toFile)
324324
//.peek(System.out::println)
325325
.forEach(File::delete);
326+
327+
if (Files.exists(tmpDir)) {
328+
logger.warning("Directory not cleaned up, please remove it manually " + tmpDir.toString());
329+
}
326330
}
327331
}
328332

0 commit comments

Comments
 (0)