Skip to content

Commit 1ced2ed

Browse files
author
Sheng Yang
committed
CS-14555: Calculated checksum before unzip
Otherwise checksum would be overrided by wrong value.
1 parent 5021274 commit 1ced2ed

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎core/src/com/cloud/storage/template/DownloadManagerImpl.java‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,13 @@ private String postDownload(String jobId) {
334334
_storage.mkdirs(resourcePath);
335335
dnld.setTmpltPath(finalResourcePath);
336336

337+
File originalTemplate = new File(td.getDownloadLocalPath());
338+
String checkSum = computeCheckSum(originalTemplate);
339+
if (checkSum == null) {
340+
s_logger.warn("Something wrong happened when try to calculate the checksum of downloaded template!");
341+
}
342+
dnld.setCheckSum(checkSum);
343+
337344
int imgSizeGigs = (int) Math.ceil(_storage.getSize(td.getDownloadLocalPath()) * 1.0d / (1024 * 1024 * 1024));
338345
imgSizeGigs++; // add one just in case
339346
long timeout = imgSizeGigs * installTimeoutPerGig;
@@ -417,9 +424,6 @@ private String postDownload(String jobId) {
417424
}
418425
}
419426

420-
String checkSum = computeCheckSum(downloadedTemplate);
421-
dnld.setCheckSum(checkSum);
422-
423427
if (!loc.save()) {
424428
s_logger.warn("Cleaning up because we're unable to save the formats");
425429
loc.purge();

0 commit comments

Comments
 (0)