mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-01 01:41:48 +08:00
Improve error handling if BITS transfer fails
This commit is contained in:
parent
b2b2c91369
commit
ce9927f732
@ -70,17 +70,23 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency)
|
||||
|
||||
if ($Dependency -ne "git") # git fails with BITS
|
||||
{
|
||||
Start-BitsTransfer -Source $url -Destination $downloadPath -ErrorAction SilentlyContinue
|
||||
try {
|
||||
Start-BitsTransfer -Source $url -Destination $downloadPath -ErrorAction Stop
|
||||
}
|
||||
else
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Enums (without resorting to C#) are only available on powershell 5+.
|
||||
$ExtractionType_NO_EXTRACTION_REQUIRED = 0
|
||||
|
Loading…
Reference in New Issue
Block a user