From d78671879b8779ef73b7b256f6d0eeb874ce6687 Mon Sep 17 00:00:00 2001 From: Aurelien Regat-Barrel Date: Sun, 30 Oct 2022 02:26:37 +0200 Subject: file(DOWNLOAD): Fix LOG with EXPECTED_HASH on download failure When `file(DOWNLOAD EXPECTED_HASH LOG )` 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 --- Source/cmFileCommand.cxx | 12 +++++++----- 1 file 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 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 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."); -- cgit v1.2.1