jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ignasi Barrera <notificati...@github.com>
Subject Re: [jclouds-labs] JCLOUDS-826: Add blob operations (#176)
Date Thu, 11 Jun 2015 08:13:03 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");

Would be more appropriate to throw an IllegalStateException here?

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