From 838cc42c99e41d69ae325a21f43ad7696ac889dd Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sat, 26 Mar 2022 22:27:11 +0100 Subject: [PATCH] Fix minor issues --- .../functions/Get-WAUAvailableVersion.ps1 | 3 +-- .../functions/Get-WAUCurrentVersion.ps1 | 2 +- Winget-AutoUpdate/functions/Get-WAUUpdateStatus.ps1 | 6 +++--- Winget-AutoUpdate/functions/Update-WAU.ps1 | 12 ++++++------ Winget-AutoUpdate/winget-upgrade.ps1 | 8 ++++---- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 b/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 index dbf1267..35d4945 100644 --- a/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 +++ b/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 @@ -8,6 +8,5 @@ function Get-WAUAvailableVersion { #Get latest stable info $WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest' } - $Script:WAULatestVersion = ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v","") - return [version]$WAULatestVersion + $Script:WAUAvailableVersion = ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v","") } \ No newline at end of file diff --git a/Winget-AutoUpdate/functions/Get-WAUCurrentVersion.ps1 b/Winget-AutoUpdate/functions/Get-WAUCurrentVersion.ps1 index 49e3e2d..f635473 100644 --- a/Winget-AutoUpdate/functions/Get-WAUCurrentVersion.ps1 +++ b/Winget-AutoUpdate/functions/Get-WAUCurrentVersion.ps1 @@ -2,5 +2,5 @@ function Get-WAUCurrentVersion{ #Get current installed version [xml]$About = Get-Content "$WorkingDir\config\about.xml" -Encoding UTF8 -ErrorAction SilentlyContinue $Script:WAUCurrentVersion = $About.app.version - return [version]$WAUCurrentVersion + Write-Log "WAU Current version : $WAUCurrentVersion" } \ No newline at end of file diff --git a/Winget-AutoUpdate/functions/Get-WAUUpdateStatus.ps1 b/Winget-AutoUpdate/functions/Get-WAUUpdateStatus.ps1 index b12e609..e18dfe1 100644 --- a/Winget-AutoUpdate/functions/Get-WAUUpdateStatus.ps1 +++ b/Winget-AutoUpdate/functions/Get-WAUUpdateStatus.ps1 @@ -3,12 +3,12 @@ function Get-WAUUpdateStatus{ [xml]$UpdateStatus = Get-Content "$WorkingDir\config\config.xml" -Encoding UTF8 -ErrorAction SilentlyContinue #Check if AutoUpdate is enabled - if ($true -eq $UpdateStatus.app.WAUautoupdate){ - Write-Log "WAU AutoUpdate is Enabled" "Green" + if ($true -eq [System.Convert]::ToBoolean($UpdateStatus.app.WAUautoupdate)){ + Write-Log "WAU AutoUpdate is enabled" "Green" $Script:WAUautoupdate = $true #Check if pre-release versions are enabled - if ($true -eq $UpdateStatus.app.WAUprerelease){ + if ($true -eq [System.Convert]::ToBoolean($UpdateStatus.app.WAUprerelease)){ Write-Log "WAU AutoUpdate Pre-release enabled" "Cyan" $Script:WAUprerelease = $true } diff --git a/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Winget-AutoUpdate/functions/Update-WAU.ps1 index f3551ca..87edde1 100644 --- a/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -1,8 +1,8 @@ -function Update-WAU ($VersionToUpdate){ +function Update-WAU { #Send available update notification $Title = $NotifLocale.local.outputs.output[2].title -f "Winget-AutoUpdate" - $Message = $NotifLocale.local.outputs.output[2].message -f $CurrentVersion, $LatestVersion.Replace("v","") + $Message = $NotifLocale.local.outputs.output[2].message -f $WAUCurrentVersion, $WAUAvailableVersion $MessageType = "info" $Balise = "Winget-AutoUpdate" Start-NotifTask $Title $Message $MessageType $Balise @@ -14,8 +14,8 @@ function Update-WAU ($VersionToUpdate){ New-Item $ZipFile -ItemType File -Force | Out-Null #Download the zip - Write-Log "Starting downloading the GitHub Repository version $VersionToUpdate" - Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/archive/refs/tags/v$($VersionToUpdate).zip/" -OutFile $ZipFile + Write-Log "Starting downloading the GitHub Repository version $WAUAvailableVersion" + Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/archive/refs/tags/v$($WAUAvailableVersion).zip/" -OutFile $ZipFile Write-Log "Download finished" "Green" #Extract Zip File @@ -37,12 +37,12 @@ function Update-WAU ($VersionToUpdate){ #Set new version to about.xml [xml]$XMLconf = Get-content "$WorkingDir\config\about.xml" -Encoding UTF8 -ErrorAction SilentlyContinue - $XMLconf.app.version = $VersionToUpdate + $XMLconf.app.version = $WAUAvailableVersion $XMLconf.Save("$WorkingDir\config\about.xml") #Send success Notif $Title = $NotifLocale.local.outputs.output[3].title -f "Winget-AutoUpdate" - $Message = $NotifLocale.local.outputs.output[3].message -f $LatestVersion + $Message = $NotifLocale.local.outputs.output[3].message -f $WAUAvailableVersion $MessageType = "success" $Balise = "Winget-AutoUpdate" Start-NotifTask $Title $Message $MessageType $Balise diff --git a/Winget-AutoUpdate/winget-upgrade.ps1 b/Winget-AutoUpdate/winget-upgrade.ps1 index 9de56d8..a9c2c21 100644 --- a/Winget-AutoUpdate/winget-upgrade.ps1 +++ b/Winget-AutoUpdate/winget-upgrade.ps1 @@ -16,18 +16,18 @@ Get-NotifLocale #Check network connectivity if (Test-Network){ + #Get Current Version + Get-WAUCurrentVersion #Check if WAU update feature is enabled Get-WAUUpdateStatus #If yes then check WAU update if ($true -eq $WAUautoupdate){ - #Get Current Version - $WAUCurrentVersion = Get-WAUCurrentVersion #Get Available Version - $WAUAvailableVersion = Get-WAUAvailableVersion + Get-WAUAvailableVersion #Compare if ($WAUAvailableVersion -gt $WAUCurrentVersion){ #If new version is available, update it - Update-WAU $WAUAvailableVersion + Update-WAU } }