mirror of https://github.com/jetkvm/kvm.git
fix(ota): trigger OTA state update on channel open in newSession function
This commit is contained in:
parent
ac79724448
commit
5e87d792d8
|
|
@ -253,9 +253,6 @@ func (s *State) doUpdate(ctx context.Context, params UpdateParams) error {
|
||||||
scopedLogger.Info().Msg("System is up to date")
|
scopedLogger.Info().Msg("System is up to date")
|
||||||
}
|
}
|
||||||
|
|
||||||
s.updating = false
|
|
||||||
s.triggerStateUpdate()
|
|
||||||
|
|
||||||
if s.rebootNeeded {
|
if s.rebootNeeded {
|
||||||
if appUpdate.customVersionUpdate || systemUpdate.customVersionUpdate {
|
if appUpdate.customVersionUpdate || systemUpdate.customVersionUpdate {
|
||||||
scopedLogger.Info().Msg("disabling auto-update due to custom version update")
|
scopedLogger.Info().Msg("disabling auto-update due to custom version update")
|
||||||
|
|
@ -267,7 +264,7 @@ func (s *State) doUpdate(ctx context.Context, params UpdateParams) error {
|
||||||
|
|
||||||
scopedLogger.Info().Msg("System Rebooting due to OTA update")
|
scopedLogger.Info().Msg("System Rebooting due to OTA update")
|
||||||
|
|
||||||
redirectUrl := fmt.Sprintf("/settings/general/update?version=%s", systemUpdate.version)
|
redirectUrl := "/settings/general/update"
|
||||||
|
|
||||||
if params.ResetConfig {
|
if params.ResetConfig {
|
||||||
scopedLogger.Info().Msg("Resetting config")
|
scopedLogger.Info().Msg("Resetting config")
|
||||||
|
|
@ -282,10 +279,10 @@ func (s *State) doUpdate(ctx context.Context, params UpdateParams) error {
|
||||||
RedirectTo: redirectUrl,
|
RedirectTo: redirectUrl,
|
||||||
}
|
}
|
||||||
|
|
||||||
// REBOOT_REDIRECT_DELAY_MS is 5 seconds in the UI,
|
// REBOOT_REDIRECT_DELAY_MS is 7 seconds in the UI,
|
||||||
// it means that healthCheckUrl will be called after 5 seconds that we send willReboot JSONRPC event
|
// it means that healthCheckUrl will be called after 7 seconds that we send willReboot JSONRPC event
|
||||||
// so we need to reboot it within 5 seconds to avoid it being called before the device is rebooted
|
// so we need to reboot it within 7 seconds to avoid it being called before the device is rebooted
|
||||||
if err := s.reboot(true, postRebootAction, 3*time.Second); err != nil {
|
if err := s.reboot(true, postRebootAction, 5*time.Second); err != nil {
|
||||||
return s.componentUpdateError("Error requesting reboot", err, &scopedLogger)
|
return s.componentUpdateError("Error requesting reboot", err, &scopedLogger)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -288,6 +288,7 @@ func newSession(config SessionConfig) (*Session, error) {
|
||||||
})
|
})
|
||||||
// Wait for channel to be open before sending initial state
|
// Wait for channel to be open before sending initial state
|
||||||
d.OnOpen(func() {
|
d.OnOpen(func() {
|
||||||
|
triggerOTAStateUpdate(otaState.ToRPCState())
|
||||||
triggerVideoStateUpdate()
|
triggerVideoStateUpdate()
|
||||||
triggerUSBStateUpdate()
|
triggerUSBStateUpdate()
|
||||||
notifyFailsafeMode(session)
|
notifyFailsafeMode(session)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue