mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-28 01:09:07 +08:00
Improve error handling if BITS transfer fails
This commit is contained in:
parent
b2b2c91369
commit
ce9927f732
@ -70,15 +70,21 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency)
|
||||
|
||||
if ($Dependency -ne "git") # git fails with BITS
|
||||
{
|
||||
Start-BitsTransfer -Source $url -Destination $downloadPath -ErrorAction SilentlyContinue
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(Test-Path $downloadPath))
|
||||
{
|
||||
Write-Host("Downloading $Dependency...")
|
||||
(New-Object System.Net.WebClient).DownloadFile($url, $downloadPath)
|
||||
try {
|
||||
Start-BitsTransfer -Source $url -Destination $downloadPath -ErrorAction Stop
|
||||
}
|
||||
catch [System.Exception] {
|
||||
# If BITS fails for any reason, delete any potentially partially downloaded files and continue
|
||||
if (Test-Path $downloadPath)
|
||||
{
|
||||
Remove-Item $downloadPath
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(Test-Path $downloadPath))
|
||||
{
|
||||
Write-Host("Downloading $Dependency...")
|
||||
(New-Object System.Net.WebClient).DownloadFile($url, $downloadPath)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user