Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More carefully check file creation status #958

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -495,17 +495,23 @@ 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