mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-24 03:27:12 +01:00
[fetchDependency] Call Get-FileHash if available, otherwise fallback
This commit is contained in:
parent
d6d5540cc5
commit
ffd91c0c1d
@ -194,17 +194,17 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency)
|
||||
performDownload $Dependency $url $downloadsDir $downloadPath $downloadVersion $requiredVersion
|
||||
|
||||
#calculating the hash
|
||||
if ($PSVersionTable.PSEdition -ne "Core")
|
||||
if (Test-Command -commandName 'Get-FileHash')
|
||||
{
|
||||
$downloadedFileHash = (Get-FileHash -Path $downloadPath -Algorithm SHA256).Hash
|
||||
}
|
||||
else
|
||||
{
|
||||
$hashAlgorithm = [Security.Cryptography.HashAlgorithm]::Create("SHA256")
|
||||
$fileAsByteArray = [io.File]::ReadAllBytes($downloadPath)
|
||||
$hashByteArray = $hashAlgorithm.ComputeHash($fileAsByteArray)
|
||||
$downloadedFileHash = -Join ($hashByteArray | ForEach-Object {"{0:x2}" -f $_})
|
||||
}
|
||||
else
|
||||
{
|
||||
$downloadedFileHash = (Get-FileHash -Path $downloadPath -Algorithm SHA256).Hash
|
||||
}
|
||||
|
||||
if ($expectedDownloadedFileHash -ne $downloadedFileHash)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user