Skip to content

Commit

Permalink
chore: add some logging and use /tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarschulte committed Nov 30, 2023
1 parent e9ba17c commit 0142aa2
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.netty.buffer.ByteBufUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.info.OsInfo;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down Expand Up @@ -47,7 +48,12 @@ public ResponseEntity getFillDisk(@PathVariable("size") String size) {
Path tempFile = null;
var deleted = true;
try {
tempFile = Files.createTempFile("diskFill", ".tmp");
if(!Files.exists(Path.of("/tmp"))) {
tempFile = Files.createTempFile("tempFile", ".tmp");
}else {
tempFile = Files.createFile(Path.of("/tmp", "tempFile.tmp"));
}
log.info("Created temporary file {}", tempFile);
FileOutputStream fo = new FileOutputStream(tempFile.toFile());
// write bytes to the file
int byteArraySize = 256 * 1024 * 1024;
Expand Down

0 comments on commit 0142aa2

Please sign in to comment.