Skip to content

Commit

Permalink
fix: drop temp files after request
Browse files Browse the repository at this point in the history
  • Loading branch information
zoobestik committed Dec 15, 2024
1 parent d410778 commit 49f1e22
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,13 @@ fun buildRunFile() {
/* language=sh */
"""
#!/usr/bin/env sh
exec java -noverify -XX:+UseParallelGC -XX:-UseCompressedOops -cp "./:lib/*" "com.compiler.server.CompilerApplicationKt"
export COMPILER_SERVER_TMP_PATH="${'$'}(mktemp -d)"
exec java -noverify \
-XX:+UseParallelGC -XX:-UseCompressedOops \
-Djava.io.tmpdir="${'$'}COMPILER_SERVER_TMP_PATH" \
-cp "./:lib/*" "com.compiler.server.CompilerApplicationKt"
""".trimIndent()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ fun <T> usingTempDirectory(action: (path: Path) -> T): T {
action(path)
} finally {
path.deleteRecursively()

System.getenv("COMPILER_SERVER_TMP_PATH")?.let {
val directory = File(it)
if (directory.exists() && directory.isDirectory) {
directory.listFiles()?.forEach { file ->
file.deleteRecursively()
}
}
}
}
}

Expand Down

0 comments on commit 49f1e22

Please sign in to comment.