-
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(windows): add state machine to control installation including apply now update 💽 #12079
feat(windows): add state machine to control installation including apply now update 💽 #12079
Conversation
background update state machine doesn't even build
…-check' into feat/windows/add-state-machine-o-updates
The event handling needs to be added for all the states
Added an event for install now when the user wants to manual start the install process straight away.
…/add-state-machine-o-updates
…s' into feat/windows/add-apply-now-update
…/add-apply-now-update
…/add-apply-now-update
…/add-apply-now-update # Keyman Conventional Commit suggestions: # # - Link to a Sentry issue with git trailer: # Fixes: _MODULE_-_ID_ # - Give credit to co-authors: # Co-authored-by: _Name_ <_email_> # - Use imperative, present tense ('attach' not 'attaches', 'attached' etc) # - Don't include a period at the end of the title # - Always include a blank line before trailers # - More: https://github.com/keymanapp/keyman/wiki/Pull-Request-and-Commit-workflow-notes
User Test ResultsTest specification and instructions ERROR: user tests have not yet been defined Test Artifacts
|
There was some dead code from before the RemoteUpdateCheck refactor was created. This is removed in this commit
* progress bar. This function is similar to DownloadUpdates, but it runs in | ||
* the background. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the function comment for DownloadUpdates
so I don't understand this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes very confusing. This comment needs updating or removing it is from when this function was the unit TOnlineUpdateCheck.DownloadUpdates
and it was actually called something like DownloadBackgroundUpdates. I ended up creating a new unit Keyman.System.DownloadUpdate
for greater clarity.
windows/src/desktop/kmshell/main/Keyman.System.DownloadUpdate.pas
Outdated
Show resolved
Hide resolved
* Result A Boolean value indicating the overall result of the | ||
* download process. | ||
*) | ||
procedure DoDownloadUpdates(SavePath: string; Params: TUpdateCheckResponse; var Result: Boolean); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a procedure and not a function?
DownloadBackGroundSavePath := IncludeTrailingPathDelimiter(TKeymanPaths.KeymanUpdateCachePath); | ||
if TUpdateCheckStorage.LoadUpdateCacheData(ucr) then | ||
begin | ||
DoDownloadUpdates(DownloadBackGroundSavePath, ucr, DownloadResult); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just use Result
directly as the parameter here (or better, make DoDownloadUpdates
into a function:
Result := DoDownloadUpdates(DownloadBackGroundSavePath, ucr);
windows/src/desktop/kmshell/main/Keyman.System.DownloadUpdate.pas
Outdated
Show resolved
Hide resolved
not Registry.ValueExists(SRegValue_AutomaticUpdates) or | ||
Registry.ReadBool(SRegValue_AutomaticUpdates); | ||
except | ||
on E: Exception do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catch-all ditto
Registry.WriteBool(SRegValue_ApplyNow, Value); | ||
Result := True; | ||
except | ||
on E: Exception do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catch-all ditto
Registry.ValueExists(SRegValue_ApplyNow) and | ||
Registry.ReadBool(SRegValue_ApplyNow); | ||
except | ||
on E: Exception do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catch-all ditto
{ Make a HTTP request out and see if updates are available for now do | ||
this all in the Idle HandleCheck message. But could be broken into an | ||
seperate state of WaitngCheck RESP } | ||
{ if Response not OK stay in the idle state and return } | ||
|
||
|
||
// If handle check event force check | ||
// CheckForUpdates := TRemoteUpdateCheck.Create(True); | ||
// try | ||
// Result:= CheckForUpdates.Run; | ||
// finally | ||
// CheckForUpdates.Free; | ||
// end; | ||
|
||
{ Response OK and Update is available } | ||
// if Result = wucSuccess then | ||
// begin | ||
// ChangeState(UpdateAvailableState); | ||
// end; | ||
|
||
// else staty in idle state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of unfinished code here? Is this going in a follow-up PR?
// Still can't go if keyman has run | ||
if HasKeymanRun then | ||
begin | ||
Result := kmShellContinue; | ||
// Exit; // Exit is not wokring for some reason. | ||
// this else is only here because the exit is not working. | ||
end | ||
else | ||
begin | ||
// Check downloaded cache if available then | ||
SavedPath := IncludeTrailingPathDelimiter | ||
(TKeymanPaths.KeymanUpdateCachePath); | ||
GetFileNamesInDirectory(SavedPath, Filenames); | ||
if Length(Filenames) = 0 then | ||
begin | ||
// Return to Idle state and check for Updates state | ||
ChangeState(IdleState); | ||
bucStateContext.CurrentState.HandleCheck; // TODO no event here | ||
Result := kmShellExit; | ||
// Exit; // again exit was not working | ||
end | ||
else | ||
begin | ||
// TODO Pop up toast here to ask user if we want to continue | ||
frmStartInstall := TfrmStartInstall.Create(nil); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleanup needed here?
Co-authored-by: Marc Durdin <[email protected]>
…/add-apply-now-update # Keyman Conventional Commit suggestions: # # - Link to a Sentry issue with git trailer: # Fixes: _MODULE_-_ID_ # - Give credit to co-authors: # Co-authored-by: _Name_ <_email_> # - Use imperative, present tense ('attach' not 'attaches', 'attached' etc) # - Don't include a period at the end of the title # - Always include a blank line before trailers # - More: https://github.com/keymanapp/keyman/wiki/Pull-Request-and-Commit-workflow-notes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Good work!
Fixes: #10210
Completed and developer tested.
Still outstanding
Extra notes:
State Transition matrix
Download updates has to be via a an event (cmd switch) and can’t be run just by kmshell event and checking the state only. This is because we want to launch a new kmshell process to run in the background. If it is Updateavailable and the kmshell.exe is started with a switch such as -c for configuration. At this point if we are on auto updates we would start the download by launching a new process, then returning continue to run configuration in the current process. So that the new process doesn’t again fork for a second time we need a switch or “event” to trigger the download.