From df74d2bc0e21883eb8a8dc4c237684d4c48937ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my?= Date: Mon, 13 Mar 2017 20:51:54 +0100 Subject: [PATCH] autoupdate: do not autodowngrade The autoupdate function did not check if the found version is newer (just !=) so it was happy to downgrade everything automatically. Downgrades can still be forced with the -force param --- bin/checkver.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/checkver.ps1 b/bin/checkver.ps1 index 8b02a479f..252b53ac0 100644 --- a/bin/checkver.ps1 +++ b/bin/checkver.ps1 @@ -19,6 +19,7 @@ if (!$app -and $update) { . "$psscriptroot\..\lib\buckets.ps1" . "$psscriptroot\..\lib\autoupdate.ps1" . "$psscriptroot\..\lib\json.ps1" +. "$psscriptroot\..\lib\versions.ps1" . "$psscriptroot\..\lib\install.ps1" # needed for hash generation if(!$dir) { $dir = "$psscriptroot\..\bucket" } @@ -163,14 +164,15 @@ while($in_progress -gt 0) { } else { write-host "$ver" -f darkred -nonewline write-host " (scoop version is $expected_ver)" -NoNewline + $update_available = (compare_versions $expected_ver $ver) -eq -1 - if ($json.autoupdate) { + if ($json.autoupdate -and $update_available) { Write-Host " autoupdate available" -f Cyan } else { Write-Host "" } - if($update -and $json.autoupdate) { + if ($update -and $update_available -and $json.autoupdate) { autoupdate $app $dir $json $ver $matches } }