summaryrefslogtreecommitdiffstats
path: root/Modules/ExternalProject-download.cmake.in
diff options
context:
space:
mode:
authorThomas Bernard <tbernard@go-engineering.de>2020-08-08 13:47:31 (GMT)
committerThomas Bernard <tbernard@go-engineering.de>2020-08-11 05:25:58 (GMT)
commitf24e34975a34c7cad6422a517a59c310d6ea00c9 (patch)
tree296c3c7b95fe34129789b2da705defc899f9bcc4 /Modules/ExternalProject-download.cmake.in
parentbb1b37ea3bbf3ad3b513ad8642ef514099699aac (diff)
downloadCMake-f24e34975a34c7cad6422a517a59c310d6ea00c9.zip
CMake-f24e34975a34c7cad6422a517a59c310d6ea00c9.tar.gz
CMake-f24e34975a34c7cad6422a517a59c310d6ea00c9.tar.bz2
ExternalProject: retry download on recoverable errors
In order to shorten the download failure of ExternalProject download steps, a download retry is only done when a recoverable network error is encountered.
Diffstat (limited to 'Modules/ExternalProject-download.cmake.in')
-rw-r--r--Modules/ExternalProject-download.cmake.in71
1 files changed, 40 insertions, 31 deletions
diff --git a/Modules/ExternalProject-download.cmake.in b/Modules/ExternalProject-download.cmake.in
index 99fb917..587e3cc 100644
--- a/Modules/ExternalProject-download.cmake.in
+++ b/Modules/ExternalProject-download.cmake.in
@@ -107,19 +107,23 @@ message(STATUS "Downloading...
dst='@LOCAL@'
timeout='@TIMEOUT_MSG@'"
)
-
+set(download_retry_codes 7 6 8 15)
+set(skip_url_list)
+set(status_code)
foreach(i RANGE ${retry_number})
- sleep_before_download(${i})
-
+ if(status_code IN_LIST download_retry_codes)
+ sleep_before_download(${i})
+ endif()
foreach(url @REMOTE@)
- message(STATUS "Using src='${url}'")
+ if(NOT url IN_LIST skip_url_list)
+ message(STATUS "Using src='${url}'")
- @TLS_VERIFY_CODE@
- @TLS_CAINFO_CODE@
- @NETRC_CODE@
- @NETRC_FILE_CODE@
+ @TLS_VERIFY_CODE@
+ @TLS_CAINFO_CODE@
+ @NETRC_CODE@
+ @NETRC_FILE_CODE@
- file(
+ file(
DOWNLOAD
"${url}" "@LOCAL@"
@SHOW_PROGRESS@
@@ -128,31 +132,36 @@ foreach(i RANGE ${retry_number})
LOG log
@USERPWD_ARGS@
@HTTP_HEADERS_ARGS@
- )
-
- list(GET status 0 status_code)
- list(GET status 1 status_string)
-
- if(status_code EQUAL 0)
- check_file_hash(has_hash hash_is_good)
- if(has_hash AND NOT hash_is_good)
- message(STATUS "Hash mismatch, removing...")
- file(REMOVE "@LOCAL@")
+ )
+
+ list(GET status 0 status_code)
+ list(GET status 1 status_string)
+
+ if(status_code EQUAL 0)
+ check_file_hash(has_hash hash_is_good)
+ if(has_hash AND NOT hash_is_good)
+ message(STATUS "Hash mismatch, removing...")
+ file(REMOVE "@LOCAL@")
+ else()
+ message(STATUS "Downloading... done")
+ return()
+ endif()
else()
- message(STATUS "Downloading... done")
- return()
+ string(APPEND logFailedURLs "error: downloading '${url}' failed
+ status_code: ${status_code}
+ status_string: ${status_string}
+ log:
+ --- LOG BEGIN ---
+ ${log}
+ --- LOG END ---
+ "
+ )
+ if(NOT status_code IN_LIST download_retry_codes)
+ list(APPEND skip_url_list "${url}")
+ break()
endif()
- else()
- string(APPEND logFailedURLs "error: downloading '${url}' failed
- status_code: ${status_code}
- status_string: ${status_string}
- log:
- --- LOG BEGIN ---
- ${log}
- --- LOG END ---
- "
- )
endif()
+ endif()
endforeach()
endforeach()