Skip to content

Commit

Permalink
PR: FILEUPLOAD-293
Browse files Browse the repository at this point in the history
Regression: Due to use of FileUtils.moveFile internally, it was no longer possible to overwrite an existing file in DiskFileItem.write(File). Fixed by deleting the target file, if possible.
  • Loading branch information
jochenw committed Feb 24, 2019
1 parent 97f0092 commit 5c2302b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
<release version="2.0" date="TBD" description="2.0 Release">
<action dev="jochen" type="update">Changing Maven coordinates, and package name, due to binary incompatible changes.</action>
<action dev="jochen" type="update">Bumping Compiler Level to 1.8.</action>
<action issue="FILEUPLOAD-293" dev="jochen" type="fix">DiskFileItem.write(File) had been changed to use FileUtils.moveFile internally, preventing an existing file as the target.</action>
</release>
<release version="1.4" date="2018-12-23" description="1.4 Release">
<action issue="FILEUPLOAD-292" dev="chtompki" type="update">Don't create un-needed resources in FileUploadBase.java</action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ public void write(File file) throws Exception {
* in a temporary location so move it to the
* desired file.
*/
if (file.exists()) {
file.delete();
}
FileUtils.moveFile(outputFile, file);
} else {
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,7 @@ public void testMoveFile() throws Exception {
assertNotNull(items);
assertFalse(items.isEmpty());
final DiskFileItem dfi = (DiskFileItem) items.get(0);
final File out = new File("target/unit-tests/DiskFileUpload/out.file");
if (out.isFile()) {
out.delete();
}
final File outDir = out.getParentFile();
if (!outDir.isDirectory()) {
outDir.mkdirs();
}
final File out = File.createTempFile("install", ".tmp");
dfi.write(out);
}
}

2 comments on commit 5c2302b

@chkpnt
Copy link
Contributor

@chkpnt chkpnt commented on 5c2302b May 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be valuable having a release 1.4.1 for this regression-fix?

@jochenw
Copy link
Contributor Author

@jochenw jochenw commented on 5c2302b May 15, 2020 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.