use new system via an update info

This commit is contained in:
2023-05-04 11:12:21 +02:00
parent 6dd6721667
commit 0d7e570676
9 changed files with 209 additions and 22 deletions

View File

@@ -8,6 +8,7 @@ Public Class Form1
Private updateConfig As New UpdateConfig
Private currentUpdating As Boolean = False
Private lastUpdateCheckResult As UpdateCheckResult = Nothing
Public Sub New()
InitializeComponent()
@@ -75,42 +76,43 @@ Public Class Form1
End If
End Sub
Private Async Function ExecuteUpdate(allowInstall As Boolean) As Task
SetStatus(LangRes.StatusText_CheckingForUpdates, MySymbols.icons8_update_16px)
Private Async Function ExecuteUpdate(doInstall As Boolean) As Task
Dim updater As New UpdateInstaller(updateConfig, GetMinecraftProfilePath)
AddHandler updater.InstallProgessUpdated, AddressOf Update_InstallProgessUpdated
AddHandler updater.CheckingProgressUpdated, AddressOf Updated_CheckingProgresssUpdated
Dim result As UpdateCheckResult = Await updater.CheckForUpdates(Not AppConfig.Instance.AllowRemoveLocalFiles)
Dim everytingOk As Boolean = False
'Check only if not pressed "install", not really needed otherwise.
If lastUpdateCheckResult Is Nothing OrElse Not doInstall Then
SetStatus(LangRes.StatusText_CheckingForUpdates, MySymbols.icons8_update_16px)
lastUpdateCheckResult = Await updater.CheckForUpdates(Not AppConfig.Instance.AllowRemoveLocalFiles)
End If
If result Is Nothing Then
If lastUpdateCheckResult Is Nothing OrElse lastUpdateCheckResult.HasError Then
SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, MySymbols.icons8_delete_16px)
ElseIf result.HasUpdates Then
SetStatus(LangRes.StatusText_UpdateAvailable, MySymbols.icons8_software_installer_16px)
If allowInstall Then
currentUpdating = True
ElseIf lastUpdateCheckResult.HasUpdates Then
If doInstall Then
SetStatus(LangRes.StatusText_Installing, MySymbols.icons8_software_installer_16px)
currentUpdating = True
If Await updater.InstallUpdates(result) Then
everytingOk = True
If Await updater.InstallUpdates(lastUpdateCheckResult) Then
lastUpdateCheckResult = Nothing 'Reset last update check, a new one would be needed now.
SetStatus(LangRes.StatusTest_EverythingOk, MySymbols.icons8_checkmark_16px)
Else
SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, MySymbols.icons8_delete_16px)
End If
currentUpdating = False
Else
SetStatus(LangRes.StatusText_UpdateAvailable, MySymbols.icons8_software_installer_16px)
End If
Else
everytingOk = True
End If
If everytingOk Then
SetStatus(LangRes.StatusTest_EverythingOk, MySymbols.icons8_checkmark_16px)
End If
End Function
Private Sub Update_InstallProgessUpdated(result As UpdateCheckResult, processedSyncs As Integer)
SetStatus(Math.Round(processedSyncs / result.SyncFiles.Count * 100, 1) & "%", MySymbols.icons8_software_installer_16px)
Dim actionCount = If(result.IsLegacy, result.SyncFiles.Count, result.UpdateActions.Count)
SetStatus(Math.Round(processedSyncs / actionCount * 100, 1) & "%", MySymbols.icons8_software_installer_16px)
End Sub
Private Sub Updated_CheckingProgresssUpdated(toCheck As Integer, processed As Integer)