mirror of https://github.com/apache/jclouds.git
Merge pull request #1162 from andrewgaul/ignore-etag-non-hex-suffix-1.5.x
Ignore ETags with non-hex suffixes
This commit is contained in:
commit
892d14ecb1
|
@ -21,6 +21,7 @@ package org.jclouds.s3.xml;
|
|||
import static org.jclouds.http.Uris.uriBuilder;
|
||||
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.crypto.CryptoStreams;
|
||||
|
@ -64,6 +65,9 @@ public class ListBucketHandler extends ParseSax.HandlerWithResult<ListBucketResp
|
|||
private String delimiter;
|
||||
private boolean isTruncated;
|
||||
|
||||
/** Some blobs have a non-hex suffix when created by multi-part uploads such Amazon S3. */
|
||||
private static final Pattern MULTIPART_BLOB_ETAG = Pattern.compile("[0-9a-f]+-[0-9]+");
|
||||
|
||||
@Inject
|
||||
public ListBucketHandler(DateService dateParser) {
|
||||
this.dateParser = dateParser;
|
||||
|
@ -99,7 +103,10 @@ public class ListBucketHandler extends ParseSax.HandlerWithResult<ListBucketResp
|
|||
} else if (qName.equals("ETag")) {
|
||||
String currentETag = currentOrNull(currentText);
|
||||
builder.eTag(currentETag);
|
||||
builder.contentMD5(CryptoStreams.hex(Strings2.replaceAll(currentETag, '"', "")));
|
||||
currentETag = Strings2.replaceAll(currentETag, '"', "");
|
||||
if (!MULTIPART_BLOB_ETAG.matcher(currentETag).matches()) {
|
||||
builder.contentMD5(CryptoStreams.hex(currentETag));
|
||||
}
|
||||
} else if (qName.equals("Size")) {
|
||||
builder.contentLength(Long.valueOf(currentOrNull(currentText)));
|
||||
} else if (qName.equals("Owner")) {
|
||||
|
|
Loading…
Reference in New Issue