MCPcopy
hub / github.com/kopia/kopia / verifyGitHubReleaseIsComplete

Function verifyGitHubReleaseIsComplete

cli/update_check.go:137–158  ·  view source on GitHub ↗

verifyGitHubReleaseIsComplete downloads checksum file to verify that the release is complete.

(ctx context.Context, releaseName string)

Source from the content-addressed store, hash-verified

135
136// verifyGitHubReleaseIsComplete downloads checksum file to verify that the release is complete.
137func verifyGitHubReleaseIsComplete(ctx context.Context, releaseName string) error {
138 ctx, cancel := context.WithTimeout(ctx, githubTimeout)
139 defer cancel()
140
141 req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf(checksumsURLFormat, repo.BuildGitHubRepo, releaseName), http.NoBody)
142 if err != nil {
143 return errors.Wrap(err, "unable to download releases checksum")
144 }
145
146 resp, err := http.DefaultClient.Do(req)
147 if err != nil {
148 return errors.Wrap(err, "unable to download releases checksum")
149 }
150
151 defer resp.Body.Close() //nolint:errcheck
152
153 if resp.StatusCode != http.StatusOK {
154 return errors.Errorf("invalid status code from GitHub: %v", resp.StatusCode)
155 }
156
157 return nil
158}
159
160func (c *App) maybeCheckForUpdates(ctx context.Context) (string, error) {
161 if v := os.Getenv(c.EnvName(checkForUpdatesEnvar)); v != "" {

Callers 1

maybeCheckGithubMethod · 0.85

Calls 2

ErrorfMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected