You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ma...@apache.org on 2006/05/04 06:53:32 UTC

svn commit: r399546 - /jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java

Author: martinc
Date: Wed May  3 21:53:30 2006
New Revision: 399546

URL: http://svn.apache.org/viewcvs?rev=399546&view=rev
Log:
Bugzilla #39160 - Cache the item size when we move it to a new location.
Submitted by Andre Schild.

Modified:
    jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java

Modified: jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java?rev=399546&r1=399545&r2=399546&view=diff
==============================================================================
--- jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java (original)
+++ jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java Wed May  3 21:53:30 2006
@@ -118,6 +118,13 @@
 
 
     /**
+     * The size of the item, in bytes. This is used to cache the size when a
+     * file item is moved from its original location.
+     */
+    private long size = -1;
+
+
+    /**
      * The threshold above which uploads will be stored on disk.
      */
     private int sizeThreshold;
@@ -266,7 +273,9 @@
      * @return The size of the file, in bytes.
      */
     public long getSize() {
-        if (cachedContent != null) {
+        if (size >= 0) {
+            return size;
+        } else if (cachedContent != null) {
             return cachedContent.length;
         } else if (dfos.isInMemory()) {
             return dfos.getData().length;
@@ -388,6 +397,8 @@
         } else {
             File outputFile = getStoreLocation();
             if (outputFile != null) {
+                // Save the length of the file
+                size = outputFile.length();
                 /*
                  * The uploaded file is being stored on disk
                  * in a temporary location so move it to the



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org