jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roman Coedo <notificati...@github.com>
Subject Re: [jclouds-labs] JCLOUDS-826: Add blob operations (#176)
Date Sat, 13 Jun 2015 16:12:24 GMT
> +      byte[] buffer = new byte[JdbcConstants.DEFAULT_CHUNK_SIZE];
> +      while ((bytes = data.read(buffer, 0, JdbcConstants.DEFAULT_CHUNK_SIZE)) != -1)
{
> +         chunks.add(chunkRepository.create(new ChunkEntity(buffer, bytes)).getId());
> +         buffer = new byte[JdbcConstants.DEFAULT_CHUNK_SIZE];
> +      }
> +      data.close();
> +      return chunks.build();
> +   }
> +
> +   private void checkIntegrity(Blob blob, BlobEntity entity) throws IOException {
> +      HashCode hash = blob.getMetadata().getContentMetadata().getContentMD5AsHashCode();
> +      if (hash != null) {
> +         HashingInputStream his = new HashingInputStream(Hashing.md5(), new JdbcInputStream(this,
entity.getPayload().getChunks()));
> +         HashCode actualHash = his.hash();
> +         if (hash.equals(actualHash)) {
> +            throw new IOException("MD5 hash code mismatch");

Some blob tests seem to expect IOException in this case

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/176/files#r32371688
Mime
View raw message