feat(windows): check update use statemachine

Also the first time remoteupdate check config runs it needs
to return true if the 'last update time' registry entry does
not exist.
This commit is contained in:
rc-swag 2025-01-17 17:20:10 +10:00
parent 7deb248c1e
commit 2467e1dd1f
2 changed files with 8 additions and 11 deletions

View file

@ -239,9 +239,8 @@ begin
begin
Exit;
end;
if Registry.ValueExists(SRegValue_LastUpdateCheckTime) and
(Now - Registry.ReadDateTime(SRegValue_LastUpdateCheckTime) >
CheckPeriod) then
if (not Registry.ValueExists(SRegValue_LastUpdateCheckTime)) or
((Now - Registry.ReadDateTime(SRegValue_LastUpdateCheckTime)) > CheckPeriod) then
begin
Result := True;
end;

View file

@ -188,7 +188,7 @@ uses
MessageIdentifiers,
Keyman.System.ExecutionHistory,
Keyman.System.KeymanSentryClient,
Keyman.System.RemoteUpdateCheck,
Keyman.System.UpdateStateMachine,
OptionsXMLRenderer,
Keyman.Configuration.System.UmodWebHttpServer,
Keyman.Configuration.System.HttpServer.App.ConfigMain,
@ -800,16 +800,14 @@ begin
end;
procedure TfrmMain.Update_CheckNow;
// TODO: epic-windows-update
// Get an instance to the state machine and call handle check so the state can change to update
// available.
var UpdateCheck : TRemoteUpdateCheck;
var
BUpdateSM : TUpdateStateMachine;
begin
UpdateCheck := TRemoteUpdateCheck.Create(True);
BUpdateSM := TUpdateStateMachine.Create(False);
try
UpdateCheck.Run;
BUpdateSM.HandleCheck;
finally
UpdateCheck.Free;
BUpdateSM.Free;
end;
DoRefresh;
end;