From bc14dc2444bd689b125a4c69bf5d7e7eeae256e3 Mon Sep 17 00:00:00 2001 From: Matthew Morley Date: Tue, 17 Oct 2023 09:10:26 -0400 Subject: [PATCH] More carefully check file creation status --- .../main/java/org/photonvision/server/RequestHandler.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/photon-server/src/main/java/org/photonvision/server/RequestHandler.java b/photon-server/src/main/java/org/photonvision/server/RequestHandler.java index c255748195..42b8e0a173 100644 --- a/photon-server/src/main/java/org/photonvision/server/RequestHandler.java +++ b/photon-server/src/main/java/org/photonvision/server/RequestHandler.java @@ -495,9 +495,9 @@ private static Optional handleTempFileCreation(UploadedFile file) { new File(Path.of(System.getProperty("java.io.tmpdir"), file.filename()).toString()); boolean makeDirsRes = tempFilePath.getParentFile().mkdirs(); - if (!makeDirsRes) { + if (!makeDirsRes && !(tempFilePath.getParentFile().exists())) { logger.error( - "There was an error while uploading " + file.filename() + " to the temp folder!"); + "There was an error while creating " + tempFilePath.getAbsolutePath() + "! Exists: " + tempFilePath.getParentFile().exists()); return Optional.empty(); } @@ -505,7 +505,7 @@ private static Optional handleTempFileCreation(UploadedFile file) { FileUtils.copyInputStreamToFile(file.content(), tempFilePath); } catch (IOException e) { logger.error( - "There was an error while uploading " + file.filename() + " to the temp folder!"); + "There was an error while copying " + file.filename() + " to the temp file " + tempFilePath.getAbsolutePath()); return Optional.empty(); }