Skip to content

Commit

Permalink
always reextract libs prior to loading (#86)
Browse files Browse the repository at this point in the history
* always reextract libs prior to loading

* fix faux warning on md5 mismatch
  • Loading branch information
shuttie authored Jun 2, 2024
1 parent 7113201 commit b65b718
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/io/github/metarank/lightgbm4j/LGBMBooster.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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("****************************************************");
Expand Down

0 comments on commit b65b718

Please sign in to comment.