mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
strip control characters from checksums
This commit is contained in:
parent
26bb89f2be
commit
3ee54432d0
@ -111,7 +111,7 @@ public class ResolverForNBIOCache implements ContentResolver {
|
|||||||
Path checksumPath = checksumPath(cachedFilePath);
|
Path checksumPath = checksumPath(cachedFilePath);
|
||||||
Files.writeString(checksumPath, localChecksumStr);
|
Files.writeString(checksumPath, localChecksumStr);
|
||||||
logger.debug(() -> "Generated local checksum and saved to cache at " + checksumPath);
|
logger.debug(() -> "Generated local checksum and saved to cache at " + checksumPath);
|
||||||
String remoteChecksum = new String(checksum.getInputStream().readAllBytes());
|
String remoteChecksum = stripControlCharacters(new String(checksum.getInputStream().readAllBytes()));
|
||||||
if (localChecksumStr.equals(remoteChecksum)) {
|
if (localChecksumStr.equals(remoteChecksum)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -123,6 +123,10 @@ public class ResolverForNBIOCache implements ContentResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String stripControlCharacters(String input) {
|
||||||
|
return input.replaceAll("[\\p{Cntrl}]+$", "");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used to download a file from a remote URL and store it in a local cache.
|
* This method is used to download a file from a remote URL and store it in a local cache.
|
||||||
* It first creates the cache directory if it doesn't exist.
|
* It first creates the cache directory if it doesn't exist.
|
||||||
@ -192,7 +196,7 @@ public class ResolverForNBIOCache implements ContentResolver {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String localChecksum = Files.readString(getOrCreateChecksum(cachedFilePath));
|
String localChecksum = Files.readString(getOrCreateChecksum(cachedFilePath));
|
||||||
String remoteChecksum = new String(checksum.getInputStream().readAllBytes());
|
String remoteChecksum = stripControlCharacters(new String(checksum.getInputStream().readAllBytes()));
|
||||||
if (localChecksum.equals(remoteChecksum)) {
|
if (localChecksum.equals(remoteChecksum)) {
|
||||||
return cachedFilePath;
|
return cachedFilePath;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user