Skip to content

Commit

Permalink
More carefully check file creation status
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Oct 17, 2023
1 parent cd83e22 commit bc14dc2
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -495,17 +495,17 @@ private static Optional<File> 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();
}

try {
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();
}

Expand Down

0 comments on commit bc14dc2

Please sign in to comment.