[vcpkg_download_distfile] Fix regression for downloading via ARIA2 and downloading with HTTP headers (#18340)

* [vcpkg_download_distfile] Use CMake to download if HTTP headers are supplied

* [vcpkg_download_distfile] Restore RENAME for the aria2 downloader

Co-authored-by: Robert Schumacher <ras0219@outlook.com>
This commit is contained in:
Robert Schumacher 2021-06-11 09:57:58 -07:00 committed by GitHub
parent c0bca7178a
commit 13c8ffbfad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -144,7 +144,7 @@ function(vcpkg_download_distfile VAR)
OUTPUT_FILE download-${vcpkg_download_distfile_FILENAME}-out.log
ERROR_FILE download-${vcpkg_download_distfile_FILENAME}-err.log
RESULT_VARIABLE error_code
WORKING_DIRECTORY ${DOWNLOADS}
WORKING_DIRECTORY "${DOWNLOADS}"
)
if (NOT "${error_code}" STREQUAL "0")
message(STATUS
@ -157,14 +157,19 @@ function(vcpkg_download_distfile VAR)
)
set(download_success 0)
else()
test_hash("${DOWNLOADS}/temp/${vcpkg_download_distfile_FILENAME}" "downloaded file" "The file may have been corrupted in transit.")
file(REMOVE
${DOWNLOADS}/download-${vcpkg_download_distfile_FILENAME}-out.log
${DOWNLOADS}/download-${vcpkg_download_distfile_FILENAME}-err.log
${DOWNLOADS}/download-${vcpkg_download_distfile_FILENAME}-detailed.log
)
get_filename_component(downloaded_file_dir "${downloaded_file_path}" DIRECTORY)
file(MAKE_DIRECTORY "${downloaded_file_dir}")
file(RENAME "${DOWNLOADS}/temp/${vcpkg_download_distfile_FILENAME}" "${downloaded_file_path}")
set(download_success 1)
endif()
elseif(vcpkg_download_distfile_SKIP_SHA512)
elseif(vcpkg_download_distfile_SKIP_SHA512 OR vcpkg_download_distfile_HEADERS)
# This is a workaround until the vcpkg tool supports downloading files without SHA512 and with headers
set(download_success 0)
set(request_headers)
if(vcpkg_download_distfile_HEADERS)