visitor = new InMemoryZipFileVisitor(realizeRegex, this.deploymentData.getTemplateEngine());
ZipUtil.walkZipFile(zipFile, visitor);
fileHashcodeMap.putAll(visitor.getFileHashcodeMap());
}
MessageDigestGenerator generator = new MessageDigestGenerator();
// calculate hashcodes for all raw files, perform in-memory realization when necessary
for (Map.Entry<File, File> rawFile : this.deploymentData.getRawFiles().entrySet()) {
// determine where the original file is and where it would go if we were writing it to disk
File currentLocationFile = rawFile.getKey();
File newLocationFile = rawFile.getValue();
String newLocationPath = rawFile.getValue().getPath();
if (!newLocationFile.isAbsolute()) {
newLocationFile = new File(this.deploymentData.getDestinationDir(), newLocationFile.getPath());
}
String hashcode;
boolean realize = false;
if (this.deploymentData.getRawFilesToRealize() != null) {
realize = this.deploymentData.getRawFilesToRealize().contains(currentLocationFile);
}
if (realize) {
debug("Realizing file [", currentLocationFile, "] in-memory to determine its hashcode");
// this entry needs to be realized, do it now in-memory (we assume realizable files will not be large)
// note: tempateEngine will never be null if we got here
FileInputStream in = new FileInputStream(currentLocationFile);
byte[] rawFileContent = StreamUtil.slurp(in);
String content = this.deploymentData.getTemplateEngine().replaceTokens(new String(rawFileContent));
// now calculate the hashcode of the realized content
generator.add(content.getBytes());
hashcode = generator.getDigestString();
} else {
debug("Streaming file [", currentLocationFile, "] in-memory to determine its hashcode");
BufferedInputStream in = new BufferedInputStream(new FileInputStream(currentLocationFile));
try {
hashcode = generator.calcDigestString(in);
} finally {
in.close();
}
}