From 08ec8200d598f0d1c50014a641d55def87f59382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20D=C3=A9moulins?= Date: Mon, 19 Jun 2023 14:59:03 +0200 Subject: [PATCH] fix: Ensure checksums are always defined when requested --- src/Public/Update-Package.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Public/Update-Package.ps1 b/src/Public/Update-Package.ps1 index bbc9867..6c9bb14 100644 --- a/src/Public/Update-Package.ps1 +++ b/src/Public/Update-Package.ps1 @@ -129,12 +129,13 @@ function Update-Package { $Env:ChocolateyPackageVersion = $global:Latest.Version.ToString() $Env:ChocolateyAllowEmptyChecksums = 'true' foreach ($a in $arch) { + "Checking hash for $a bit version..." | result $Env:chocolateyForceX86 = if ($a -eq '32') { 'true' } else { '' } try { #rm -force -recurse -ea ignore $pkg_path .\tools\chocolateyInstall.ps1 | result } catch { - if ( "$_" -notlike 'au_break: *') { throw $_ } else { + if ( "$_" -notlike 'au_break: *') { throw } else { $filePath = "$_" -replace 'au_break: ' if (!(Test-Path $filePath)) { throw "Can't find file path to checksum" } @@ -153,6 +154,10 @@ function Update-Package { } } } + # Sanity check: ensure checksum is defined (rare bug!) + if (!$global:Latest.Item('Checksum' + $a)) { + throw "Hash for $a bit version is missing." + } } }