From 5c005815b327a77bac834c5a4a403a163d29d0ce Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Fri, 11 Aug 2023 13:26:34 +0200 Subject: [PATCH] build(traffic_light_fine_detector): simplify download logic Signed-off-by: Esteve Fernandez --- .../CMakeLists.txt | 35 +++++-------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/perception/traffic_light_fine_detector/CMakeLists.txt b/perception/traffic_light_fine_detector/CMakeLists.txt index 1db9fdfb3b0c2..d67802ca1c4f4 100644 --- a/perception/traffic_light_fine_detector/CMakeLists.txt +++ b/perception/traffic_light_fine_detector/CMakeLists.txt @@ -92,36 +92,19 @@ function(download FILE_NAME FILE_HASH) if(${FILE_HASH} STREQUAL ${EXISTING_FILE_HASH}) message(STATUS "same ${FILE_NAME}") message(STATUS "File already exists.") - else() - message(STATUS "diff ${FILE_NAME}") - message(STATUS "File hash changes. Downloading now ...") - if(DOWNLOAD_ARTIFACTS) - file(DOWNLOAD ${DATA_DIR}/${FILE_NAME} ${FILE_PATH} STATUS DOWNLOAD_STATUS TIMEOUT 300) - list(GET DOWNLOAD_STATUS 0 STATUS_CODE) - list(GET DOWNLOAD_STATUS 1 ERROR_MESSAGE) - else() - message(WARNING "Skipped download for ${FILE_NAME} (enable by setting DOWNLOAD_ARTIFACTS)") - file(MAKE_DIRECTORY "${DATA_PATH}") - return() - endif() - endif() - else() - message(STATUS "not found ${FILE_NAME}") - if(DOWNLOAD_ARTIFACTS) - message(STATUS "File doesn't exists. Downloading now ...") - file(DOWNLOAD ${DATA_DIR}/${FILE_NAME} ${FILE_PATH} STATUS DOWNLOAD_STATUS TIMEOUT 300) - list(GET DOWNLOAD_STATUS 0 STATUS_CODE) - list(GET DOWNLOAD_STATUS 1 ERROR_MESSAGE) - else() - message(WARNING "Skipped download for ${FILE_NAME} (enable by setting DOWNLOAD_ARTIFACTS)") - file(MAKE_DIRECTORY "${DATA_PATH}") return() endif() + message(STATUS "diff ${FILE_NAME}") endif() - if(${STATUS_CODE} EQUAL 0) - message(STATUS "Download completed successfully!") + if(DOWNLOAD_ARTIFACTS) + message(STATUS "Downloading now ...") + file(DOWNLOAD ${DATA_DIR}/${FILE_NAME} ${FILE_PATH} STATUS DOWNLOAD_STATUS TIMEOUT 300) + list(GET DOWNLOAD_STATUS 0 STATUS_CODE) + list(GET DOWNLOAD_STATUS 1 ERROR_MESSAGE) else() - message(FATAL_ERROR "Error occurred during download: ${ERROR_MESSAGE}") + message(WARNING "Skipped download for ${FILE_NAME} (enable by setting DOWNLOAD_ARTIFACTS)") + file(MAKE_DIRECTORY "${DATA_PATH}") + return() endif() endfunction() download(tlr_yolox_s_batch_1.onnx ${PRETRAINED_MODEL_BATCH_1_HASH})