handleExplicitOptionalUpdate handles explicit update requests. Unlike automatic updates, this skips TTL caching and doesn't record attempt timestamps.
(parentCtx context.Context, res updatepolicy.Result)
| 84 | // handleExplicitOptionalUpdate handles explicit update requests. |
| 85 | // Unlike automatic updates, this skips TTL caching and doesn't record attempt timestamps. |
| 86 | func handleExplicitOptionalUpdate(parentCtx context.Context, res updatepolicy.Result) error { |
| 87 | currentVer := displayVersion(res.CurrentVersion) |
| 88 | latestVer := displayVersion(res.LatestVersion) |
| 89 | |
| 90 | fmt.Println(tui.RenderUpdating(currentVer, latestVer)) |
| 91 | |
| 92 | updateCtx, cancel := context.WithTimeout(parentCtx, 5*time.Minute) |
| 93 | defer cancel() |
| 94 | |
| 95 | if err := runSelfUpdate(updateCtx, res); err != nil { |
| 96 | releaseURL := fmt.Sprintf("https://github.com/Thunder-Compute/thunder-cli/releases/tag/%s", releaseTag(res)) |
| 97 | fmt.Fprintln(os.Stderr, tui.RenderUpdateFailed(err, releaseURL)) |
| 98 | return err |
| 99 | } |
| 100 | |
| 101 | // Finalize update immediately if possible (Windows only) |
| 102 | binPath, _ := getCurrentBinaryPath() |
| 103 | if binPath != "" { |
| 104 | shouldReexec, err := autoupdate.TryFinalizeStagedUpdateImmediately(parentCtx, binPath) |
| 105 | if err != nil || shouldReexec { |
| 106 | fmt.Println(tui.RenderUpdateSuccess()) |
| 107 | return nil |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | fmt.Println(tui.RenderUpdateSuccess()) |
| 112 | return nil |
| 113 | } |
no test coverage detected