More carefully check file creation status (#958)

This commit is contained in:
Matt
2023-10-17 16:23:05 -04:00
committed by GitHub
parent 47bd077bbb
commit 441caf03c0

View File

@@ -537,9 +537,12 @@ public class RequestHandler {
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();
}
@@ -547,7 +550,10 @@ public class RequestHandler {
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();
}