diff options
author | Aurelien Regat-Barrel <arb@cyberkarma.net> | 2022-11-09 11:03:11 (GMT) |
---|---|---|
committer | Aurelien Regat-Barrel <arb@cyberkarma.net> | 2022-11-09 21:44:36 (GMT) |
commit | 8c3cf2716a952f8d35f10113bbd6a41729e70c26 (patch) | |
tree | c2ee735622b68a7442e4c6f02629a985ab43617c /Source/cmFileCommand.cxx | |
parent | 9758dbd9d4122b03bf1257524545b188f3de91f2 (diff) | |
download | CMake-8c3cf2716a952f8d35f10113bbd6a41729e70c26.zip CMake-8c3cf2716a952f8d35f10113bbd6a41729e70c26.tar.gz CMake-8c3cf2716a952f8d35f10113bbd6a41729e70c26.tar.bz2 |
file(DOWNLOAD EXPECTED_HASH): better error message when download failed
Diffstat (limited to 'Source/cmFileCommand.cxx')
-rw-r--r-- | Source/cmFileCommand.cxx | 14 |
1 files changed, 9 insertions, 5 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; } } |