Skip to content
Permalink
Browse files
Raise embedded if into parent if.
  • Loading branch information
garydgregory committed Feb 28, 2021
1 parent 1d3c22f commit dd4a9ff37a87d9dfbc56f5049a8d6023da774007
Showing 2 changed files with 13 additions and 17 deletions.
@@ -402,11 +402,9 @@ public void write(final File file) throws Exception {
* in a temporary location so move it to the
* desired file.
*/
if (file.exists()) {
if (!file.delete()) {
throw new FileUploadException(
"Cannot write uploaded file to disk!");
}
if (file.exists() && !file.delete()) {
throw new FileUploadException(
"Cannot write uploaded file to disk!");
}
FileUtils.moveFile(outputFile, file);
} else {
@@ -94,18 +94,16 @@ public FileItemStreamImpl(final FileItemIteratorImpl pFileItemIterator, final St
contentType = pContentType;
formField = pFormField;
final long fileSizeMax = fileItemIteratorImpl.getFileSizeMax();
if (fileSizeMax != -1) { // Check if limit is already exceeded
if (pContentLength != -1
&& pContentLength > fileSizeMax) {
final FileSizeLimitExceededException e =
new FileSizeLimitExceededException(
format("The field %s exceeds its maximum permitted size of %s bytes.",
fieldName, Long.valueOf(fileSizeMax)),
pContentLength, fileSizeMax);
e.setFileName(pName);
e.setFieldName(pFieldName);
throw new FileUploadIOException(e);
}
if (fileSizeMax != -1 && pContentLength != -1
&& pContentLength > fileSizeMax) {
final FileSizeLimitExceededException e =
new FileSizeLimitExceededException(
format("The field %s exceeds its maximum permitted size of %s bytes.",
fieldName, Long.valueOf(fileSizeMax)),
pContentLength, fileSizeMax);
e.setFileName(pName);
e.setFieldName(pFieldName);
throw new FileUploadIOException(e);
}
// OK to construct stream now
final ItemInputStream itemStream = fileItemIteratorImpl.getMultiPartStream().newInputStream();

0 comments on commit dd4a9ff

Please sign in to comment.