> @@ -202,9 +203,18 @@ public String putBlob(final String containerName, final
> Blob blob) throws IOExce
> Files.createParentDirs(outputFile);
> his = new HashingInputStream(Hashing.md5(), payload.openStream());
> Files.asByteSink(outputFile).writeFrom(his);
> - payload.getContentMetadata().setContentMD5(his.hash().asBytes());
> - String eTag =
> base16().lowerCase().encode(payload.getContentMetadata().getContentMD5());
> - return eTag;
> + HashCode actualHashCode = his.hash();
> + byte[] expectedHashCodeBytes =
> payload.getContentMetadata().getContentMD5();
> + if (expectedHashCodeBytes != null) {
> + HashCode expectedHashCode =
> HashCode.fromBytes(expectedHashCodeBytes);
> + if (!actualHashCode.equals(expectedHashCode)) {
> + throw new IOException("MD5 hash code mismatch, actual: " +
> actualHashCode +
> + " expected: " + expectedHashCode);
> + }
> + }
> + byte[] actualHashCodeBytes = actualHashCode.asBytes();
> + payload.getContentMetadata().setContentMD5(actualHashCodeBytes);
Do we need this if `actualHashCode.equals(expectedHashCode)`? Or does that
still not guarantee that also `payload.getContentMetadata().getContentMD5() =
expectedHashCodeBytes == actualHashCode.asBytes()`?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/382/files#r13114851