mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 02:39:48 -06:00
file(DOWNLOAD EXPECTED_HASH): better error message when download failed
This commit is contained in:
@@ -2107,6 +2107,14 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
|
||||
// Verify MD5 sum if requested:
|
||||
//
|
||||
if (hash) {
|
||||
if (res != CURLE_OK) {
|
||||
status.SetError(cmStrCat(
|
||||
"DOWNLOAD cannot compute hash on failed download\n"
|
||||
" status: [",
|
||||
static_cast<int>(res), ";\"", ::curl_easy_strerror(res), "\"]"));
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string actualHash = hash->HashFile(file);
|
||||
if (actualHash.empty()) {
|
||||
status.SetError("DOWNLOAD cannot compute hash on downloaded file");
|
||||
@@ -2130,11 +2138,7 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
|
||||
expectedHash,
|
||||
"]\n"
|
||||
" actual hash: [",
|
||||
actualHash,
|
||||
"]\n"
|
||||
" status: [",
|
||||
static_cast<int>(res), ";\"",
|
||||
::curl_easy_strerror(res), "\"]\n"));
|
||||
actualHash, "]\n"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
for file: \[.*/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-build/hash-mismatch.txt\]
|
||||
expected hash: \[0123456789abcdef0123456789abcdef01234567\]
|
||||
actual hash: \[da39a3ee5e6b4b0d3255bfef95601890afd80709\]
|
||||
status: \[0;"No error"\]
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)
|
||||
|
||||
Reference in New Issue
Block a user