summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-11-10 15:08:41 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-11-10 15:08:54 (GMT)
commit566064ea5e2daeb0f85bb5f08edad980c921d95d (patch)
treeadd15ca99c86664cf50c3c48326c173b1a2cf0f2
parent8dc7f6a4434ea8018272d6af4b3f096de4d682dc (diff)
parent8c3cf2716a952f8d35f10113bbd6a41729e70c26 (diff)
downloadCMake-566064ea5e2daeb0f85bb5f08edad980c921d95d.zip
CMake-566064ea5e2daeb0f85bb5f08edad980c921d95d.tar.gz
CMake-566064ea5e2daeb0f85bb5f08edad980c921d95d.tar.bz2
Merge topic 'better-file-download-failure-msg'
8c3cf2716a file(DOWNLOAD EXPECTED_HASH): better error message when download failed Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !7888
-rw-r--r--Source/cmFileCommand.cxx14
-rw-r--r--Tests/RunCMake/file/DOWNLOAD-hash-mismatch-stderr.txt1
2 files changed, 9 insertions, 6 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index fe38db5..cc9b256 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -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;
}
}
diff --git a/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-stderr.txt b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-stderr.txt
index 406e315..7a356c1 100644
--- a/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-stderr.txt
+++ b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-stderr.txt
@@ -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\)