Exemplo n.º 1
0
 private byte[] getHash(JarArchive jarArchive) {
   FileSnapshot s = inputFilesSnapshot.findSnapshot(jarArchive.file);
   if (s != null) {
     return s.getHash();
   }
   return hasher.hash(jarArchive.file);
 }
 private byte[] hash(
     List<String> visitedFilePaths, Set<File> visitedDirs, byte[] combinedHash, File[] toHash) {
   for (File file : toHash) {
     file = GFileUtils.canonicalise(file);
     if (file.isDirectory()) {
       if (visitedDirs.add(file)) {
         // in theory, awkward symbolic links can lead to recursion problems.
         // TODO - figure out a way to test it. I only tested it 'manually' and the feature is
         // needed.
         combinedHash = hash(visitedFilePaths, visitedDirs, combinedHash, file.listFiles());
       }
     } else {
       visitedFilePaths.add(file.getAbsolutePath());
       combinedHash = Bytes.concat(combinedHash, hasher.hash(file));
     }
   }
   return combinedHash;
 }