From 48f29fff358abb5ead8833946e21bb15b2c0783b Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Fri, 19 Jan 2024 01:08:54 -0500 Subject: [PATCH 1/2] utils.pwsh: Move curl options to array --- utils.pwsh/Invoke-SafeWebRequest.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utils.pwsh/Invoke-SafeWebRequest.ps1 b/utils.pwsh/Invoke-SafeWebRequest.ps1 index d23af671f..50de85a1e 100644 --- a/utils.pwsh/Invoke-SafeWebRequest.ps1 +++ b/utils.pwsh/Invoke-SafeWebRequest.ps1 @@ -57,7 +57,14 @@ function Invoke-SafeWebRequest { } } - Invoke-External curl --fail --location $(if ( $Env:CI -eq $null ) { '--progress-bar' }) --output $OutFile @HeaderStrings $Uri + $CurlOptions = @( + '--fail' + '--location' + $(if ( $Env:CI -eq $null ) { '--progress-bar' }) + '--output', "$OutFile" + ) + + Invoke-External curl @CurlOptions @HeaderStrings $Uri $NewHash = Get-FileHash -Path $OutFile -Algorithm $Algorithm } From 268730a8d8b1b6901a46cdba44b2c39567d32a3c Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Tue, 30 Jul 2024 13:09:14 -0400 Subject: [PATCH 2/2] utils.pwsh: Add support for curl resume Note that there is a bug in older versions of curl that can prevent curl from successfully interpreting a fully downloaded file as completed. The bug was fixed on October 30, 2023 and is now available on curl included with Windows. Fixed in curl 8.5.0. https://github.com/curl/curl/commit/225db9196a71a19132a4c334f256b59854afc70c --- utils.pwsh/Invoke-SafeWebRequest.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils.pwsh/Invoke-SafeWebRequest.ps1 b/utils.pwsh/Invoke-SafeWebRequest.ps1 index 50de85a1e..d7308c39f 100644 --- a/utils.pwsh/Invoke-SafeWebRequest.ps1 +++ b/utils.pwsh/Invoke-SafeWebRequest.ps1 @@ -64,6 +64,11 @@ function Invoke-SafeWebRequest { '--output', "$OutFile" ) + $CurlVersionResult = $($(Invoke-External curl --version) -join ' ') -match 'curl (?\d+\.\d+\.\d+)' + if ( ( $Matches.CurlVersion -ge '8.5.0' ) -and $Resume ) { + $CurlOptions += @('-C', '-') + } + Invoke-External curl @CurlOptions @HeaderStrings $Uri $NewHash = Get-FileHash -Path $OutFile -Algorithm $Algorithm