mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-24 11:37: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
|
performDownload $Dependency $url $downloadsDir $downloadPath $downloadVersion $requiredVersion
|
||||||
|
|
||||||
#calculating the hash
|
#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")
|
$hashAlgorithm = [Security.Cryptography.HashAlgorithm]::Create("SHA256")
|
||||||
$fileAsByteArray = [io.File]::ReadAllBytes($downloadPath)
|
$fileAsByteArray = [io.File]::ReadAllBytes($downloadPath)
|
||||||
$hashByteArray = $hashAlgorithm.ComputeHash($fileAsByteArray)
|
$hashByteArray = $hashAlgorithm.ComputeHash($fileAsByteArray)
|
||||||
$downloadedFileHash = -Join ($hashByteArray | ForEach-Object {"{0:x2}" -f $_})
|
$downloadedFileHash = -Join ($hashByteArray | ForEach-Object {"{0:x2}" -f $_})
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$downloadedFileHash = (Get-FileHash -Path $downloadPath -Algorithm SHA256).Hash
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($expectedDownloadedFileHash -ne $downloadedFileHash)
|
if ($expectedDownloadedFileHash -ne $downloadedFileHash)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user