Skip to content

Commit

Permalink
utils.pwsh: Add support for curl resume
Browse files Browse the repository at this point in the history
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.
curl/curl@225db91
  • Loading branch information
RytoEX committed Aug 1, 2024
1 parent ccc47dc commit 4196405
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions utils.pwsh/Invoke-SafeWebRequest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ function Invoke-SafeWebRequest {
'--output', "$OutFile"
)

$CurlVersionResult = $($(Invoke-External curl --version) -join ' ') -match 'curl (?<CurlVersion>\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
Expand Down

0 comments on commit 4196405

Please sign in to comment.