MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / handleExplicitOptionalUpdate

Function handleExplicitOptionalUpdate

cmd/update.go:86–113  ·  view source on GitHub ↗

handleExplicitOptionalUpdate handles explicit update requests. Unlike automatic updates, this skips TTL caching and doesn't record attempt timestamps.

(parentCtx context.Context, res updatepolicy.Result)

Source from the content-addressed store, hash-verified

84// handleExplicitOptionalUpdate handles explicit update requests.
85// Unlike automatic updates, this skips TTL caching and doesn't record attempt timestamps.
86func 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}

Callers 1

runUpdateCommandFunction · 0.85

Calls 8

RenderUpdatingFunction · 0.92
RenderUpdateFailedFunction · 0.92
RenderUpdateSuccessFunction · 0.92
displayVersionFunction · 0.85
runSelfUpdateFunction · 0.85
releaseTagFunction · 0.85
getCurrentBinaryPathFunction · 0.85

Tested by

no test coverage detected