2
0
Fork 0
mirror of https://github.com/ethauvin/bld.git synced 2025-04-25 16:27:11 -07:00

Minor cleanup

This commit is contained in:
Geert Bevin 2023-05-11 21:53:41 -04:00
parent 0cf76977cc
commit 91bc4d271e

View file

@ -415,21 +415,22 @@ public class Wrapper {
var distribution_file = new File(DISTRIBUTIONS_DIR, bldFileName(version)); var distribution_file = new File(DISTRIBUTIONS_DIR, bldFileName(version));
var distribution_sources_file = new File(DISTRIBUTIONS_DIR, bldSourcesFileName(version)); var distribution_sources_file = new File(DISTRIBUTIONS_DIR, bldSourcesFileName(version));
if (distribution_file.exists()) { // if this is a snapshot and the distribution file exists,
if (is_snapshot) { // ensure that it's the latest by comparing hashes
var download_md5 = readString(version, new URL(downloadUrl(version, bldFileName(download_version)) + ".md5")); if (is_snapshot && distribution_file.exists()) {
try { var download_md5 = readString(version, new URL(downloadUrl(version, bldFileName(download_version)) + ".md5"));
var digest = MessageDigest.getInstance("MD5"); try {
digest.update(FileUtils.readBytes(distribution_file)); var digest = MessageDigest.getInstance("MD5");
if (!download_md5.equals(encodeHexLower(digest.digest()))) { digest.update(FileUtils.readBytes(distribution_file));
distribution_file.delete(); if (!download_md5.equals(encodeHexLower(digest.digest()))) {
distribution_sources_file.delete(); distribution_file.delete();
} distribution_sources_file.delete();
} catch (NoSuchAlgorithmException ignore) {
} }
} catch (NoSuchAlgorithmException ignore) {
} }
} }
// download distribution jars if necessary
if (!distribution_file.exists()) { if (!distribution_file.exists()) {
downloadDistribution(distribution_file, downloadUrl(version, bldFileName(download_version))); downloadDistribution(distribution_file, downloadUrl(version, bldFileName(download_version)));
} }