Пример #1
0
 private void recalcHashes(DataNode item) throws IOException {
   if (item.dirty == null) {
     return; // not dirty, which means no children are dirty
   }
   // only directories have derived hashes
   if (item instanceof DirectoryNode) {
     DirectoryNode dirNode = (DirectoryNode) item;
     for (DataNode child : dirNode) {
       recalcHashes(child);
     }
     ByteArrayOutputStream bout = new ByteArrayOutputStream();
     hashCalc.sort(dirNode.getChildren());
     String newHash = hashCalc.calcHash(dirNode, bout);
     item.setHash(newHash);
     byte[] arrTriplets = bout.toByteArray();
     blobStore.setBlob(newHash, arrTriplets);
     log.info(
         "recalcHashes: "
             + item.name
             + " children:"
             + dirNode.members.size()
             + " hash="
             + newHash);
   }
 }
Пример #2
0
 public List<ITriplet> find(String hash) {
   // return DataItem.findByHash(hash, session);
   byte[] arr = blobStore.getBlob(hash);
   if (arr == null) {
     return null;
   }
   ByteArrayInputStream bin = new ByteArrayInputStream(arr);
   try {
     return hashCalc.parseTriplets(bin);
   } catch (IOException ex) {
     throw new RuntimeException(ex);
   }
 }
Пример #3
0
 public boolean dirExists(String hash) {
   return blobStore.hasBlob(hash);
 }