Merge pull request #511 from Romanitho/reinstall
Add 1 more retry for more specific casespull/515/head
commit
6189fa1274
|
@ -44,7 +44,6 @@ Function Update-App ($app) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#Check if application updated properly
|
#Check if application updated properly
|
||||||
$FailedToUpgrade = $false
|
|
||||||
$ConfirmInstall = Confirm-Installation $($app.Id) $($app.AvailableVersion)
|
$ConfirmInstall = Confirm-Installation $($app.Id) $($app.AvailableVersion)
|
||||||
|
|
||||||
if ($ConfirmInstall -ne $true) {
|
if ($ConfirmInstall -ne $true) {
|
||||||
|
@ -53,12 +52,14 @@ Function Update-App ($app) {
|
||||||
$PendingReboot = Test-PendingReboot
|
$PendingReboot = Test-PendingReboot
|
||||||
if ($PendingReboot -eq $true) {
|
if ($PendingReboot -eq $true) {
|
||||||
Write-ToLog "-> A Pending Reboot lingers and probably prohibited $($app.Name) from upgrading...`n-> ...an install for $($app.Name) is NOT executed!" "Red"
|
Write-ToLog "-> A Pending Reboot lingers and probably prohibited $($app.Name) from upgrading...`n-> ...an install for $($app.Name) is NOT executed!" "Red"
|
||||||
$FailedToUpgrade = $true
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
#If app failed to upgrade, run Install command
|
#If app failed to upgrade, run Install command (2 tries max - some apps get uninstalled after single "Install" command.)
|
||||||
Write-ToLog "-> An upgrade for $($app.Name) failed, now trying an install instead..." "Yellow"
|
$retry = 1
|
||||||
|
While (($ConfirmInstall -eq $false) -and ($retry -le 2)) {
|
||||||
|
|
||||||
|
Write-ToLog "-> An upgrade for $($app.Name) failed, now trying an install instead... ($retry/2)" "Yellow"
|
||||||
|
|
||||||
if ($ModsOverride) {
|
if ($ModsOverride) {
|
||||||
Write-ToLog "-> Running (overriding default): Winget install --id $($app.Id) -e --accept-package-agreements --accept-source-agreements -s winget --force --override $ModsOverride"
|
Write-ToLog "-> Running (overriding default): Winget install --id $($app.Id) -e --accept-package-agreements --accept-source-agreements -s winget --force --override $ModsOverride"
|
||||||
|
@ -76,24 +77,20 @@ Function Update-App ($app) {
|
||||||
|
|
||||||
#Check if application installed properly
|
#Check if application installed properly
|
||||||
$ConfirmInstall = Confirm-Installation $($app.Id) $($app.AvailableVersion)
|
$ConfirmInstall = Confirm-Installation $($app.Id) $($app.AvailableVersion)
|
||||||
if ($ConfirmInstall -eq $false) {
|
$retry += 1
|
||||||
$FailedToUpgrade = $true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($FailedToUpgrade)
|
switch ($ConfirmInstall) {
|
||||||
{
|
|
||||||
# Upgrade/install was successful
|
# Upgrade/install was successful
|
||||||
$false
|
$true {
|
||||||
{
|
|
||||||
if ($ModsInstalled) {
|
if ($ModsInstalled) {
|
||||||
Write-ToLog "Modifications for $($app.Id) after upgrade/install are being applied..." "Yellow"
|
Write-ToLog "Modifications for $($app.Id) after upgrade/install are being applied..." "Yellow"
|
||||||
& "$ModsInstalled"
|
& "$ModsInstalled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# Upgrade/install was unsuccessful
|
# Upgrade/install was unsuccessful
|
||||||
$true
|
$false {
|
||||||
{
|
|
||||||
if ($ModsNotInstalled) {
|
if ($ModsNotInstalled) {
|
||||||
Write-ToLog "Modifications for $($app.Id) after a failed upgrade/install are being applied..." "Yellow"
|
Write-ToLog "Modifications for $($app.Id) after a failed upgrade/install are being applied..." "Yellow"
|
||||||
& "$ModsNotInstalled"
|
& "$ModsNotInstalled"
|
||||||
|
@ -104,7 +101,7 @@ Function Update-App ($app) {
|
||||||
Write-ToLog "########## WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '$($App.Id)' ##########" "Gray"
|
Write-ToLog "########## WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '$($App.Id)' ##########" "Gray"
|
||||||
|
|
||||||
#Notify installation
|
#Notify installation
|
||||||
if ($FailedToUpgrade -eq $false) {
|
if ($ConfirmInstall -eq $true) {
|
||||||
|
|
||||||
#Send success updated app notification
|
#Send success updated app notification
|
||||||
Write-ToLog "$($app.Name) updated to $($app.AvailableVersion) !" "Green"
|
Write-ToLog "$($app.Name) updated to $($app.AvailableVersion) !" "Green"
|
||||||
|
|
Loading…
Reference in New Issue