Skip to content

Commit

Permalink
get_latest_conan_version(): retry up to 2 times
Browse files Browse the repository at this point in the history
GitHub fails to respond surprisingly often.
  • Loading branch information
valgur committed Jul 16, 2024
1 parent 6e6a070 commit 7672df4
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions conan_provider.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -556,15 +556,19 @@ endfunction()

function(get_latest_conan_version VERSION_VARIABLE)
set(json_file "${CMAKE_BINARY_DIR}/conan_latest_release.json")
file(DOWNLOAD "https://api.github.com/repos/conan-io/conan/releases/latest"
"${json_file}"
INACTIVITY_TIMEOUT 5
STATUS status)
list(GET status 0 status_code)
if(NOT status_code EQUAL 0)
list(GET status 1 message)
message(FATAL_ERROR "CMake-Conan: Failed to get the latest Conan version info: ${message} (${status_code})")
endif()
foreach(_retry_counter RANGE 3)
file(DOWNLOAD "https://api.github.com/repos/conan-io/conan/releases/latest"
"${json_file}"
INACTIVITY_TIMEOUT 15
STATUS status)
list(GET status 0 status_code)
if(NOT status_code EQUAL 0)
list(GET status 1 message)
message(WARNING "CMake-Conan: Failed to get the latest Conan version info: ${message} (${status_code})")
continue()
endif()
break()
endforeach()
file(READ "${json_file}" json ENCODING UTF-8)
string(REGEX MATCH "\"tag_name\": \"([^\"]+)\"" _ "${json}")
if(NOT _)
Expand Down

0 comments on commit 7672df4

Please sign in to comment.