use of com.thoughtworks.go.validation.ChecksumValidator in project gocd by gocd.
the class FileHandler method handle.
public void handle(InputStream stream) throws IOException {
FileOutputStream fileOutputStream = null;
try {
fileOutputStream = FileUtils.openOutputStream(artifact);
if (LOG.isInfoEnabled()) {
LOG.info(format("[Artifact File Download] [%s] Download of artifact %s started", new Date(), artifact.getName()));
}
IOUtils.copyLarge(stream, fileOutputStream);
if (LOG.isInfoEnabled()) {
LOG.info(format("[Artifact File Download] [%s] Download of artifact %s ended", new Date(), artifact.getName()));
}
} finally {
IOUtils.closeQuietly(fileOutputStream);
}
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(artifact);
if (LOG.isInfoEnabled()) {
LOG.info(format("[Artifact File Download] [%s] Checksum computation of artifact %s started", new Date(), artifact.getName()));
}
String artifactMD5 = md5Hex(inputStream);
new ChecksumValidator(artifactMd5Checksums).validate(srcFile, artifactMD5, checksumValidationPublisher);
if (LOG.isInfoEnabled()) {
LOG.info(format("[Artifact File Download] [%s] Checksum computation of artifact %s ended", new Date(), artifact.getName()));
}
} finally {
IOUtils.closeQuietly(inputStream);
}
}
use of com.thoughtworks.go.validation.ChecksumValidator in project gocd by gocd.
the class DirHandler method handle.
public void handle(InputStream stream) throws IOException {
ZipInputStream zipInputStream = new ZipInputStream(stream);
LOG.info(format("[Agent Fetch Artifact] Downloading from '%s' to '%s'. Will read from Socket stream to compute MD5 and write to file", srcFile, destOnAgent.getAbsolutePath()));
long before = System.currentTimeMillis();
new ZipUtil(new ZipUtil.ZipEntryHandler() {
public void handleEntry(ZipEntry entry, InputStream stream) throws IOException {
LOG.info(format("[Agent Fetch Artifact] Downloading a directory from '%s' to '%s'. Handling the entry: '%s'", srcFile, destOnAgent.getAbsolutePath(), entry.getName()));
new ChecksumValidator(artifactMd5Checksums).validate(getSrcFilePath(entry), md5Hex(stream), checksumValidationPublisher);
}
}).unzip(zipInputStream, destOnAgent);
LOG.info(format("[Agent Fetch Artifact] Downloading a directory from '%s' to '%s'. Took: %sms", srcFile, destOnAgent.getAbsolutePath(), System.currentTimeMillis() - before));
}
Aggregations