Skip to content

Commit 5d89c04

Browse files
author
njzjz-bot
committed
fix(cmake): abort failed Paddle bootstrap steps
Stop configuration before extraction, cleanup, or cache mutation when the Paddle download fails integrity or transport checks. Also fail on extraction errors and unpack into the configured build directory. Coding-Agent: Codex Codex-Version: codex-cli 0.144.6 Model: gpt-5.6-sol Reasoning-Effort: xhigh
1 parent 8f7c2c7 commit 5d89c04

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

source/CMakeLists.txt

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,33 @@ if(ENABLE_PADDLE)
8484
endif()
8585
set(TGZ_FILE "${CMAKE_BINARY_DIR}/paddle_inference.tgz")
8686
set(EXTRACTED_DIR "${CMAKE_BINARY_DIR}/paddle_inference_install_dir")
87-
file(DOWNLOAD ${DOWNLOAD_URL} ${TGZ_FILE}
88-
EXPECTED_HASH SHA256=${DOWNLOAD_SHA256})
87+
file(
88+
DOWNLOAD ${DOWNLOAD_URL} ${TGZ_FILE}
89+
EXPECTED_HASH SHA256=${DOWNLOAD_SHA256}
90+
STATUS PADDLE_DOWNLOAD_STATUS)
91+
list(GET PADDLE_DOWNLOAD_STATUS 0 PADDLE_DOWNLOAD_STATUS_CODE)
92+
list(GET PADDLE_DOWNLOAD_STATUS 1 PADDLE_DOWNLOAD_STATUS_MESSAGE)
93+
if(NOT PADDLE_DOWNLOAD_STATUS_CODE EQUAL 0)
94+
message(
95+
FATAL_ERROR
96+
"Failed to download Paddle inference library from ${DOWNLOAD_URL} (status ${PADDLE_DOWNLOAD_STATUS_CODE}): ${PADDLE_DOWNLOAD_STATUS_MESSAGE}"
97+
)
98+
endif()
8999
message(STATUS "Downloading finished, extracting...")
90-
execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xzvf ${TGZ_FILE}
91-
OUTPUT_QUIET)
100+
execute_process(
101+
COMMAND ${CMAKE_COMMAND} -E tar -xzvf ${TGZ_FILE}
102+
OUTPUT_QUIET
103+
ERROR_VARIABLE PADDLE_EXTRACT_ERROR
104+
RESULT_VARIABLE PADDLE_EXTRACT_STATUS
105+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
106+
if(NOT PADDLE_EXTRACT_STATUS STREQUAL "0")
107+
message(
108+
FATAL_ERROR
109+
"Failed to extract ${TGZ_FILE} (status ${PADDLE_EXTRACT_STATUS}): ${PADDLE_EXTRACT_ERROR}"
110+
)
111+
endif()
112+
# Cache the inferred location only after both steps succeed. Otherwise a
113+
# failed configure would cause retries to skip this download block.
92114
file(REMOVE ${TGZ_FILE})
93115
set(PADDLE_INFERENCE_DIR
94116
${EXTRACTED_DIR}

0 commit comments

Comments
 (0)