This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch wicket-8.x
in repository https://gitbox.apache.org/repos/asf/wicket.git


The following commit(s) were added to refs/heads/wicket-8.x by this push:
     new d66a7c3  WICKET-6630 Delete (temp) file before writing to it
     new 8e170dc  Merge pull request #346 from laurenshop/WICKET-6630
d66a7c3 is described below

commit d66a7c361f726ee43d249145329fbe986c02d7d9
Author: Laurens Hop <[email protected]>
AuthorDate: Wed Jan 16 17:05:45 2019 +0100

    WICKET-6630 Delete (temp) file before writing to it
    
    As of commons-fileupload 1.4, FileUtils.moveFile() is used to write the 
uploaded contents to the provided file. This implementation does not allow the 
destination to be present.
---
 .../java/org/apache/wicket/markup/html/form/upload/FileUpload.java    | 4 ++++
 1 file changed, 4 insertions(+)

diff --git 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUpload.java
 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUpload.java
index 1fafbe4..9718e30 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUpload.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUpload.java
@@ -231,6 +231,10 @@ public class FileUpload implements IClusterable
         */
        public void writeTo(final File file) throws Exception
        {
+               if (file.isFile() && file.exists())
+               {                       
+                       file.delete();
+               }
                item.write(file);
        }
 

Reply via email to