mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-18 14:43:04 +08:00
[vcpkg_download_distfile] Now downloads in a temp dir and rename to the target location
This commit is contained in:
parent
66ad158be4
commit
24c3f87bf4
@ -38,7 +38,12 @@ function(vcpkg_download_distfile VAR)
|
|||||||
set(oneValueArgs FILENAME SHA512)
|
set(oneValueArgs FILENAME SHA512)
|
||||||
set(multipleValuesArgs URLS)
|
set(multipleValuesArgs URLS)
|
||||||
cmake_parse_arguments(vcpkg_download_distfile "" "${oneValueArgs}" "${multipleValuesArgs}" ${ARGN})
|
cmake_parse_arguments(vcpkg_download_distfile "" "${oneValueArgs}" "${multipleValuesArgs}" ${ARGN})
|
||||||
|
|
||||||
set(downloaded_file_path ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME})
|
set(downloaded_file_path ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME})
|
||||||
|
set(download_file_path_part "${DOWNLOADS}/temp/${vcpkg_download_distfile_FILENAME}")
|
||||||
|
|
||||||
|
file(REMOVE_RECURSE "${DOWNLOADS}/temp")
|
||||||
|
file(MAKE_DIRECTORY "${DOWNLOADS}/temp")
|
||||||
|
|
||||||
function(test_hash FILE_KIND CUSTOM_ERROR_ADVICE)
|
function(test_hash FILE_KIND CUSTOM_ERROR_ADVICE)
|
||||||
message(STATUS "Testing integrity of ${FILE_KIND}...")
|
message(STATUS "Testing integrity of ${FILE_KIND}...")
|
||||||
@ -65,13 +70,13 @@ function(vcpkg_download_distfile VAR)
|
|||||||
# Tries to download the file.
|
# Tries to download the file.
|
||||||
foreach(url IN LISTS vcpkg_download_distfile_URLS)
|
foreach(url IN LISTS vcpkg_download_distfile_URLS)
|
||||||
message(STATUS "Downloading ${url}...")
|
message(STATUS "Downloading ${url}...")
|
||||||
file(DOWNLOAD ${url} ${downloaded_file_path} STATUS download_status)
|
file(DOWNLOAD ${url} "${download_file_path_part}" STATUS download_status SHOW_PROGRESS)
|
||||||
list(GET download_status 0 status_code)
|
list(GET download_status 0 status_code)
|
||||||
if (NOT "${status_code}" STREQUAL "0")
|
if (NOT "${status_code}" STREQUAL "0")
|
||||||
message(STATUS "Downloading ${url}... Failed. Status: ${download_status}")
|
message(STATUS "Downloading ${url}... Failed. Status: ${download_status}")
|
||||||
file(REMOVE ${downloaded_file_path})
|
|
||||||
set(download_success 0)
|
set(download_success 0)
|
||||||
else()
|
else()
|
||||||
|
file(RENAME ${download_file_path_part} ${downloaded_file_path})
|
||||||
message(STATUS "Downloading ${url}... OK")
|
message(STATUS "Downloading ${url}... OK")
|
||||||
set(download_success 1)
|
set(download_success 1)
|
||||||
break()
|
break()
|
||||||
|
Loading…
Reference in New Issue
Block a user