DaanHoogland commented on a change in pull request #5831:
URL: https://github.com/apache/cloudstack/pull/5831#discussion_r797746727
##########
File path:
utils/src/main/java/org/apache/cloudstack/utils/security/DigestHelper.java
##########
@@ -131,4 +140,14 @@ protected static boolean isAlgorithmPresent(String
checksum) {
public static String getHashValueFromChecksumValue(String checksum) {
return isAlgorithmPresent(checksum) ? new
ChecksumValue(checksum).getChecksum() : checksum;
}
+
+ public static String calculateChecksum(File file) {
+ try (InputStream is = Files.newInputStream(Paths.get(file.getPath())))
{
+ return DigestUtils.md5Hex(is);
+ } catch (IOException e) {
+ String errMsg = "Failed to calculate template checksum";
+ LOGGER.error(errMsg, e);
Review comment:
rather no stacktraces on error level. my take on this is if you want it
log the message twice and add the trace to a debug level message. Also the
exception is being re-thrown so we need to think about whether the stacktrace
is needed at this point.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]