refactor: enhance redirect URL handling in TryUpdate function

This commit is contained in:
Adam Shiervani 2025-10-23 15:17:07 +00:00
parent 03a05c135a
commit 35d717610d
1 changed files with 14 additions and 1 deletions

15
ota.go
View File

@ -489,9 +489,22 @@ func TryUpdate(ctx context.Context, deviceId string, includePreRelease bool) err
if rebootNeeded { if rebootNeeded {
scopedLogger.Info().Msg("System Rebooting due to OTA update") scopedLogger.Info().Msg("System Rebooting due to OTA update")
// Build redirect URL with conditional query parameters
redirectUrl := "/settings/general/update"
queryParams := url.Values{}
if systemUpdateAvailable {
queryParams.Set("systemVersion", remote.SystemVersion)
}
if appUpdateAvailable {
queryParams.Set("appVersion", remote.AppVersion)
}
if len(queryParams) > 0 {
redirectUrl += "?" + queryParams.Encode()
}
postRebootAction := &PostRebootAction{ postRebootAction := &PostRebootAction{
HealthCheck: "/device/status", HealthCheck: "/device/status",
RedirectUrl: "/settings/general/update?version=" + remote.SystemVersion, RedirectUrl: redirectUrl,
} }
if err := hwReboot(true, postRebootAction, 10*time.Second); err != nil { if err := hwReboot(true, postRebootAction, 10*time.Second); err != nil {