From d685279825d342a4f0c947bb19763d945a8e2b84 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Tue, 24 Sep 2019 12:28:54 +0200 Subject: [PATCH 1/2] Use HTTPS URLs in pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index daefa756..6fe5e4a9 100644 --- a/pom.xml +++ b/pom.xml @@ -46,14 +46,14 @@ repo.jenkins-ci.org - http://repo.jenkins-ci.org/public/ + https://repo.jenkins-ci.org/public/ repo.jenkins-ci.org - http://repo.jenkins-ci.org/public/ + https://repo.jenkins-ci.org/public/ From 49103941d1832f3f0b3f5932c05f4a962b397258 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 21 Aug 2021 16:14:14 -0700 Subject: [PATCH 2/2] [JENKINS-66326] Prepare SCM Sync Configuration for core Guava upgrade --- .../utils/Checksums.java | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/main/java/hudson/plugins/scm_sync_configuration/utils/Checksums.java b/src/main/java/hudson/plugins/scm_sync_configuration/utils/Checksums.java index c66ae455..c3a98306 100644 --- a/src/main/java/hudson/plugins/scm_sync_configuration/utils/Checksums.java +++ b/src/main/java/hudson/plugins/scm_sync_configuration/utils/Checksums.java @@ -1,11 +1,10 @@ package hudson.plugins.scm_sync_configuration.utils; -import com.google.common.io.ByteStreams; -import com.google.common.io.Files; - import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.util.zip.CRC32; +import java.util.zip.CheckedInputStream; import java.util.zip.Checksum; /** @@ -13,14 +12,33 @@ * Utility class allowing to provide easy access to jenkins files checksums */ public class Checksums { + + private static final int BUF_SIZE = 0x1000; // 4K + public static boolean fileAndByteArrayContentAreEqual(File file, byte[] content) throws IOException { if(!file.exists()){ return content == null || content.length == 0; } + long fileChecksum; + CheckedInputStream in = null; + try { + in = new CheckedInputStream(new FileInputStream(file), createChecksum()); + byte[] buffer = new byte[BUF_SIZE]; + while (in.read(buffer, 0, buffer.length) >= 0) { + // keep updating checksum + } + fileChecksum = in.getChecksum().getValue(); + } finally { + if (in != null) { + in.close(); + } + } + Checksum checksum = createChecksum(); - long fileChecksum = Files.getChecksum(file, checksum); - long contentChecksum = ByteStreams.getChecksum(ByteStreams.newInputStreamSupplier(content), checksum); + checksum.update(content, 0, content.length); + long contentChecksum = checksum.getValue(); + return fileChecksum == contentChecksum; }