aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-02-02 16:00:30 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2017-02-02 16:00:30 -0800
commitce9927f7327bc71ade246108a7d984deda6293fd (patch)
tree3247c24273a9c45ef2749832a3c5e3b5e4f5b278 /scripts
parentb2b2c9136918ed3ef85961c5c2885b9562d07d1d (diff)
downloadvcpkg-ce9927f7327bc71ade246108a7d984deda6293fd.tar.gz
vcpkg-ce9927f7327bc71ade246108a7d984deda6293fd.zip
Improve error handling if BITS transfer fails
Diffstat (limited to 'scripts')
-rw-r--r--scripts/fetchDependency.ps120
1 files changed, 13 insertions, 7 deletions
diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1
index b56bf1087..8d31b0edb 100644
--- a/scripts/fetchDependency.ps1
+++ b/scripts/fetchDependency.ps1
@@ -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
+ 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
+ }
+ }
}
- else
+ if (!(Test-Path $downloadPath))
{
- if (!(Test-Path $downloadPath))
- {
- Write-Host("Downloading $Dependency...")
- (New-Object System.Net.WebClient).DownloadFile($url, $downloadPath)
- }
+ Write-Host("Downloading $Dependency...")
+ (New-Object System.Net.WebClient).DownloadFile($url, $downloadPath)
}
}