From b65b718a341438dae9b88383765034e54d8668c7 Mon Sep 17 00:00:00 2001 From: yadda yadda yadda Date: Sun, 2 Jun 2024 21:31:32 +0200 Subject: [PATCH] always reextract libs prior to loading (#86) * always reextract libs prior to loading * fix faux warning on md5 mismatch --- .../java/io/github/metarank/lightgbm4j/LGBMBooster.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/io/github/metarank/lightgbm4j/LGBMBooster.java b/src/main/java/io/github/metarank/lightgbm4j/LGBMBooster.java index ba23d42..665150b 100644 --- a/src/main/java/io/github/metarank/lightgbm4j/LGBMBooster.java +++ b/src/main/java/io/github/metarank/lightgbm4j/LGBMBooster.java @@ -134,6 +134,7 @@ private static void loadNative(String path, String name) throws IOException, Uns File libFile = new File(tmp + File.separator + name); if (libFile.exists()) { logger.info(libFile + " already exists"); + extractResource(path + name, name, libFile); } else { extractResource(path + name, name, libFile); } @@ -162,6 +163,11 @@ private static void extractResource(String path, String name, File dest) throws try { byte[] digest = MessageDigest.getInstance("MD5").digest(libByteStream.toByteArray()); String checksum = new BigInteger(1, digest).toString(16); + for (int i=0; i<32 - checksum.length(); i++) { + checksum = "0" + checksum; + } + + if (!checksum.equals(expectedDigest)) { logger.warn("\n\n\n"); logger.warn("****************************************************");