Copilot commented on code in PR #11814:
URL: https://github.com/apache/cloudstack/pull/11814#discussion_r2486270564
##########
services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/template/DownloadManagerImpl.java:
##########
@@ -616,25 +620,24 @@ private void
setPermissionsForTheDownloadedTemplate(String resourcePath, Resourc
_storage.setWorldReadableAndWriteable(templateProperties);
}
- private String checkOrCreateTheChecksum(DownloadJob dnld, File targetFile)
{
- ChecksumValue oldValue = new ChecksumValue(dnld.getChecksum());
- ChecksumValue newValue = null;
+ private String checkAndUpdateChecksum(DownloadJob job, File targetFile) {
+ final String downloadType = job.getResourceType().name().toLowerCase();
+ ChecksumValue oldValue = new ChecksumValue(job.getChecksum());
+ ChecksumValue newValue;
try {
newValue = computeCheckSum(oldValue.getAlgorithm(), targetFile);
- if (logger.isDebugEnabled()) {
- logger.debug(String.format("computed checksum: %s", newValue));
- }
+ logger.debug("Computed {} checksum: {}", downloadType, newValue);
} catch (NoSuchAlgorithmException e) {
- return "checksum algorithm not recognised: " +
oldValue.getAlgorithm();
+ return String.format("checksum algorithm not recognised: %s",
oldValue.getAlgorithm());
}
- if (StringUtils.isNotBlank(dnld.getChecksum()) &&
!oldValue.equals(newValue)) {
- return "checksum \"" + newValue + "\" didn't match the given
value, \"" + oldValue + "\"";
+ if (StringUtils.isNotBlank(job.getChecksum()) &&
!oldValue.equals(newValue)) {
+ return String.format("checksum \"%s\" didn't match the given
value, \"%s\"", newValue, oldValue);
}
- String checksum = newValue.toString();
+ String checksum = newValue == null ? null : newValue.toString();
if (checksum == null) {
- logger.warn("Something wrong happened when try to calculate the
checksum of downloaded template!");
+ logger.warn("Something wrong happened when try to calculate the
checksum of downloaded {}}!", downloadType);
Review Comment:
Remove extra closing brace in log message. The message contains '}}!' which
should be '}'.
--
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]