summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurelien Regat-Barrel <arb@cyberkarma.net>2022-10-30 02:26:37 +0200
committerBrad King <brad.king@kitware.com>2022-10-30 08:42:19 -0400
commitd78671879b8779ef73b7b256f6d0eeb874ce6687 (patch)
tree5514ae5e3d1b5c219725688c07cf1b5663421856
parent59ae2543165b836d01b88fe0ba4e22ecd549e239 (diff)
downloadcmake-d78671879b8779ef73b7b256f6d0eeb874ce6687.tar.gz
file(DOWNLOAD): Fix LOG with EXPECTED_HASH on download failure
When `file(DOWNLOAD <url> EXPECTED_HASH <hash> LOG <logs>)` fails to download the requested file, the hash check will also fail and make the command exit without actually returning the curl logs as requested by the `LOG` argument. Report the log before checking the hash. Issue: #24093
-rw-r--r--Source/cmFileCommand.cxx12
1 files changed, 7 insertions, 5 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 421ff12557..fe38db53e8 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2090,6 +2090,13 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
::curl_global_cleanup();
+ // Ensure requested curl logs are returned (especially in case of failure)
+ //
+ if (!logVar.empty()) {
+ chunkDebug.push_back(0);
+ status.GetMakefile().AddDefinition(logVar, chunkDebug.data());
+ }
+
// Explicitly flush/close so we can measure the md5 accurately.
//
if (!file.empty()) {
@@ -2132,11 +2139,6 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
}
}
- if (!logVar.empty()) {
- chunkDebug.push_back(0);
- status.GetMakefile().AddDefinition(logVar, chunkDebug.data());
- }
-
return true;
#else
status.SetError("DOWNLOAD not supported by bootstrap cmake.");