Use an in-memory stream in YamlCreate.ps1 for hash computation (#478)

Co-authored-by: Kevin Larkin (MS) <kevinla@microsoft.com>
This commit is contained in:
chausner
2020-06-30 18:39:39 +02:00
committed by GitHub
parent 4ee595af9d
commit 9bd42bbfad

View File

@@ -5,9 +5,6 @@
# define variables # define variables
$OFS = "`r`n" #linebreak $OFS = "`r`n" #linebreak
$tempFolder=$env:TEMP;
# Create a temporary file to generate a sha256 value.
$Hashfile=$tempFolder + "\TempfileName.txt"
# Prompt for URL # Prompt for URL
While ($url.Length -eq 0) { While ($url.Length -eq 0) {
@@ -17,16 +14,19 @@ $OFS
write-host "Downloading URL. This will take awhile... " -ForeGroundColor Blue write-host "Downloading URL. This will take awhile... " -ForeGroundColor Blue
$WebClient = New-Object System.Net.WebClient $WebClient = New-Object System.Net.WebClient
# This downloads the installer # This downloads the installer
try { try {
$WebClient.DownloadFile($URL, $Hashfile) $stream = $WebClient.OpenRead($URL)
} }
catch { catch {
write-host "Error downloading file. Please run the script again." -ForeGroundColor red write-host "Error downloading file. Please run the script again." -ForeGroundColor red
exit 1 exit 1
} }
# This command will get the sha256 hash # This command will get the sha256 hash
$Hash=get-filehash $hashfile $Hash=get-filehash -InputStream $stream
$stream.Close()
$string = "Url: " + $URL ; $string = "Url: " + $URL ;