mirror of https://github.com/apache/jclouds.git
blobstore/download-blob should .writeTo instead of c.c.io/copy.
This commit is contained in:
parent
50b1aa3cae
commit
d2c6a6f17e
|
@ -45,6 +45,7 @@ See http://code.google.com/p/jclouds for details."
|
||||||
options.ListContainerOptions]
|
options.ListContainerOptions]
|
||||||
[org.jclouds.encryption.internal JCEEncryptionService]
|
[org.jclouds.encryption.internal JCEEncryptionService]
|
||||||
[java.util Arrays]
|
[java.util Arrays]
|
||||||
|
[java.security DigestOutputStream MessageDigest]
|
||||||
[com.google.common.collect ImmutableSet]))
|
[com.google.common.collect ImmutableSet]))
|
||||||
|
|
||||||
(try
|
(try
|
||||||
|
@ -293,10 +294,10 @@ container, name, string -> etag"
|
||||||
(defmethod download-blob OutputStream [container-name name target blobstore
|
(defmethod download-blob OutputStream [container-name name target blobstore
|
||||||
& [retries]]
|
& [retries]]
|
||||||
(let [blob (get-blob container-name name blobstore)
|
(let [blob (get-blob container-name name blobstore)
|
||||||
digest-stream (.md5OutputStream ;; TODO: not all clouds use MD5
|
digest-stream (DigestOutputStream.
|
||||||
*encryption-service* target)]
|
target (MessageDigest/getInstance "MD5"))]
|
||||||
(io/copy (.getContent blob) digest-stream)
|
(.writeTo (.getPayload blob) digest-stream)
|
||||||
(let [digest (.getMD5 digest-stream)
|
(let [digest (.digest (.getMessageDigest digest-stream))
|
||||||
metadata-digest (.getContentMD5 (.getMetadata blob))]
|
metadata-digest (.getContentMD5 (.getMetadata blob))]
|
||||||
(when-not (Arrays/equals digest metadata-digest)
|
(when-not (Arrays/equals digest metadata-digest)
|
||||||
(if (<= (or retries 0) *max-retries*)
|
(if (<= (or retries 0) *max-retries*)
|
||||||
|
|
Loading…
Reference in New Issue