archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r919307 - /archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java
Date Fri, 05 Mar 2010 06:09:53 GMT
Author: brett
Date: Fri Mar  5 06:09:53 2010
New Revision: 919307

URL: http://svn.apache.org/viewvc?rev=919307&view=rev
Log:
[MRM-1356] handle chunked / unknown length requests correctly

Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java?rev=919307&r1=919306&r2=919307&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java
Fri Mar  5 06:09:53 2010
@@ -303,13 +303,16 @@
             }
 
             // TODO: a bad deployment shouldn't delete an existing file - do we need to write
to a temporary location first?
-            if ( inputContext.getContentLength() != localFile.length() )
+            long expectedContentLength = inputContext.getContentLength();
+            long actualContentLength = localFile.length();
+            // length of -1 is given for a chunked request or unknown length, in which case
we accept what was uploaded
+            if ( expectedContentLength >= 0 && expectedContentLength != actualContentLength
)
             {
-                FileUtils.deleteQuietly( localFile );
-
                 String msg =
-                    "Content Header length was " + inputContext.getContentLength() + " but
was " + localFile.length();
+                    "Content Header length was " + expectedContentLength + " but was " +
actualContentLength;
                 log.debug( "Upload failed: " + msg );
+
+                FileUtils.deleteQuietly( localFile );
                 throw new DavException( HttpServletResponse.SC_BAD_REQUEST, msg );
             }
 



Mime
View raw message