diff --git a/cmake/common/buildspec_common.cmake b/cmake/common/buildspec_common.cmake index d5d02cb994c94e..db9b57436d9809 100644 --- a/cmake/common/buildspec_common.cmake +++ b/cmake/common/buildspec_common.cmake @@ -128,15 +128,16 @@ function(_check_dependencies) if(NOT EXISTS "${dependencies_dir}/${file}") message(STATUS "Downloading ${url}") - file(DOWNLOAD "${url}" "${dependencies_dir}/${file}" STATUS download_status EXPECTED_HASH SHA256=${hash}) + file(DOWNLOAD "${url}" "${dependencies_dir}/${file}.tmp" STATUS download_status EXPECTED_HASH SHA256=${hash}) list(GET download_status 0 error_code) list(GET download_status 1 error_message) - if(error_code GREATER 0) + if(error_code) + file(REMOVE "${dependencies_dir}/${file}.tmp") message(STATUS "Downloading ${url} - Failure") message(FATAL_ERROR "Unable to download ${url}, failed with error: ${error_message}") - file(REMOVE "${dependencies_dir}/${file}") else() + file(RENAME "${dependencies_dir}/${file}.tmp" "${dependencies_dir}/${file}") message(STATUS "Downloading ${url} - done") endif() endif()