aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2018-04-06 15:22:50 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2018-04-06 19:31:19 -0700
commitd5a1e1054120c993560e5de1c6ad8ac16131d356 (patch)
tree0e06ba32984e5d72d6d3d1efac11f937abbd2c0c
parentb87aeb77deb7b6cdc7e78d0b006243a15993e78c (diff)
downloadvcpkg-d5a1e1054120c993560e5de1c6ad8ac16131d356.tar.gz
vcpkg-d5a1e1054120c993560e5de1c6ad8ac16131d356.zip
[ps1] Verify hash for already present files. Dont check for path twice
-rw-r--r--scripts/VcpkgPowershellUtils.ps123
-rw-r--r--scripts/fetchTool.ps14
2 files changed, 8 insertions, 19 deletions
diff --git a/scripts/VcpkgPowershellUtils.ps1 b/scripts/VcpkgPowershellUtils.ps1
index 63069f44d..f6882409b 100644
--- a/scripts/VcpkgPowershellUtils.ps1
+++ b/scripts/VcpkgPowershellUtils.ps1
@@ -105,9 +105,9 @@ function vcpkgGetSHA512([Parameter(Mandatory=$true)][string]$filePath)
function vcpkgCheckEqualFileHash( [Parameter(Mandatory=$true)][string]$url,
[Parameter(Mandatory=$true)][string]$filePath,
- [Parameter(Mandatory=$true)][string]$expectedHash,
- [Parameter(Mandatory=$true)][string]$actualHash)
+ [Parameter(Mandatory=$true)][string]$expectedHash)
{
+ $actualHash = vcpkgGetSHA512 $filePath
if ($expectedHash -ne $actualHash)
{
Write-Host ("`nFile does not have expected hash:`n" +
@@ -123,11 +123,6 @@ function vcpkgDownloadFile( [Parameter(Mandatory=$true)][string]$url,
[Parameter(Mandatory=$true)][string]$downloadPath,
[Parameter(Mandatory=$true)][string]$sha512)
{
- if (Test-Path $downloadPath)
- {
- return
- }
-
if ($url -match "github")
{
if ([System.Enum]::IsDefined([Net.SecurityProtocolType], "Tls12"))
@@ -155,10 +150,7 @@ function vcpkgDownloadFile( [Parameter(Mandatory=$true)][string]$url,
}
$wc.DownloadFile($url, $downloadPartPath)
-
- $actualHash = vcpkgGetSHA512 $downloadPartPath
- vcpkgCheckEqualFileHash -url $url -filePath $downloadPath -expectedHash $sha512 -actualHash $actualHash
-
+ vcpkgCheckEqualFileHash -url $url -filePath $downloadPartPath -expectedHash $sha512
Move-Item -Path $downloadPartPath -Destination $downloadPath
}
@@ -167,11 +159,6 @@ function vcpkgDownloadFileWithAria2( [Parameter(Mandatory=$true)][string]$ari
[Parameter(Mandatory=$true)][string]$downloadPath,
[Parameter(Mandatory=$true)][string]$sha512)
{
- if (Test-Path $downloadPath)
- {
- return
- }
-
vcpkgCreateParentDirectoryIfNotExists $downloadPath
$downloadPartPath = "$downloadPath.part"
vcpkgRemoveItem $downloadPartPath
@@ -186,9 +173,7 @@ function vcpkgDownloadFileWithAria2( [Parameter(Mandatory=$true)][string]$ari
throw
}
- $actualHash = vcpkgGetSHA512 $downloadPartPath
- vcpkgCheckEqualFileHash -url $url -filePath $downloadPath -expectedHash $sha512 -actualHash $actualHash
-
+ vcpkgCheckEqualFileHash -url $url -filePath $downloadPartPath -expectedHash $sha512
Move-Item -Path $downloadPartPath -Destination $downloadPath
}
diff --git a/scripts/fetchTool.ps1 b/scripts/fetchTool.ps1
index c1e8d87fc..8de642674 100644
--- a/scripts/fetchTool.ps1
+++ b/scripts/fetchTool.ps1
@@ -61,6 +61,10 @@ function fetchToolInternal([Parameter(Mandatory=$true)][string]$tool)
Write-Host "Downloading $tool... done."
}
+ else
+ {
+ vcpkgCheckEqualFileHash -url $url -filePath $downloadPath -expectedHash $toolData.sha512
+ }
if ($isArchive)
{