Skip to content

Commit fa3659a

Browse files
committed
Fetch SHA256 checksum and handle failures
Replace returning the checksum link with an actual SHA256 value by invoking Invoke-EvergreenRestMethod on the downloads.windows.checksumLink, splitting the response to extract the checksum, and assigning it to Sha256. Add try/catch to emit a warning and set Sha256 to $null on failure, preserving existing metadata (Version, Build, Edition, Date, Size, Type). Improves robustness when checksum retrieval fails.
1 parent 3c88b4b commit fa3659a

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Evergreen/Shared/Get-JetBrainsApp.ps1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,22 @@ function Get-JetBrainsApp {
2323
Write-Warning -Message "$($MyInvocation.MyCommand): 'downloads.windows.link' property is null; from '$uri'."
2424
}
2525
else {
26+
27+
try {
28+
$Sha256 = Invoke-EvergreenRestMethod -Uri $UpdateFeed.$($Edition.Value).downloads.windows.checksumLink
29+
$Sha256 = ($Sha256 -split '\s+')[0]
30+
}
31+
catch {
32+
Write-Warning -Message "$($MyInvocation.MyCommand): Failed to retrieve the SHA256 checksum from '$($UpdateFeed.$($Edition.Value).downloads.windows.checksumLink)'. Error: $_"
33+
$Sha256 = $null
34+
}
35+
2636
# Construct the output; Return the custom object to the pipeline
2737
$PSObject = [PSCustomObject] @{
2838
Version = $UpdateFeed.$($Edition.Value).version
2939
Build = $UpdateFeed.$($Edition.Value).build
3040
Edition = $Edition.Key
31-
Sha256 = $UpdateFeed.$($Edition.Value).downloads.windows.checksumLink
41+
Sha256 = $Sha256
3242
Date = ConvertTo-DateTime -DateTime $UpdateFeed.$($Edition.Value).date -Pattern $res.Get.Update.DatePattern
3343
Size = $UpdateFeed.$($Edition.Value).downloads.windows.size
3444
Type = Get-FileType -File $UpdateFeed.$($Edition.Value).downloads.windows.link

0 commit comments

Comments
 (0)