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

Function checkIfUpdateNeeded

cmd/root.go:263–297  ·  view source on GitHub ↗
(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

261}
262
263func checkIfUpdateNeeded(cmd *cobra.Command) {
264 if shouldSkipUpdateCheck(cmd) {
265 return
266 }
267
268 if os.Getenv("TNR_NO_SELFUPDATE") == "1" {
269 return
270 }
271
272 ctx := context.Background()
273
274 // Apply any previously staged Windows update before checking again.
275 if err := autoupdate.FinalizeWindowsSwap(); err != nil {
276 fmt.Fprintf(os.Stderr, "Warning: failed to finalize staged Windows update: %v\n", err)
277 }
278
279 policyResult, err := updatepolicy.Check(ctx, version.BuildVersion, false)
280 if err != nil {
281 // Update checks hit external services (GitHub API). Any failure —
282 // timeouts, 5xx, network errors — is not actionable from Sentry.
283 fmt.Fprintf(os.Stderr, "Warning: update check failed: %v\n", err)
284 return
285 }
286
287 if !policyResult.Mandatory && !policyResult.Optional {
288 return
289 }
290
291 if policyResult.Mandatory {
292 handleMandatoryUpdate(ctx, policyResult, false)
293 return
294 }
295
296 handleOptionalUpdate(ctx, policyResult)
297}
298
299func handleMandatoryUpdate(parentCtx context.Context, res updatepolicy.Result, manual bool) {
300 displayCurrent := displayVersion(res.CurrentVersion)

Callers 1

initFunction · 0.85

Calls 5

FinalizeWindowsSwapFunction · 0.92
CheckFunction · 0.92
shouldSkipUpdateCheckFunction · 0.85
handleMandatoryUpdateFunction · 0.85
handleOptionalUpdateFunction · 0.85

Tested by

no test coverage detected