MCPcopy Create free account
hub / github.com/compozy/agh / openDownloadResponse

Method openDownloadResponse

internal/registry/github/client.go:534–564  ·  view source on GitHub ↗
(
	ctx context.Context,
	repo repoSlug,
	release *release,
	selection releaseSelection,
)

Source from the content-addressed store, hash-verified

532}
533
534func (c *Client) openDownloadResponse(
535 ctx context.Context,
536 repo repoSlug,
537 release *release,
538 selection releaseSelection,
539) (*http.Response, string, int64, error) {
540 switch {
541 case selection.asset != nil:
542 response, err := c.doRequest(
543 ctx,
544 firstNonEmpty(selection.asset.URL, selection.asset.BrowserDownloadURL),
545 acceptBinary,
546 )
547 if err != nil {
548 return nil, "", -1, fmt.Errorf("github: download asset for %q: %w", repo.full, err)
549 }
550 size := int64(-1)
551 if selection.asset.Size > 0 {
552 size = selection.asset.Size
553 }
554 return response, strings.TrimSpace(selection.asset.Digest), size, nil
555 case selection.useTarball:
556 response, err := c.doRequest(ctx, strings.TrimSpace(release.TarballURL), acceptBinary)
557 if err != nil {
558 return nil, "", -1, fmt.Errorf("github: download source archive for %q: %w", repo.full, err)
559 }
560 return response, "", -1, nil
561 default:
562 return nil, "", -1, fmt.Errorf("github: no download candidate resolved for %q", repo.full)
563 }
564}
565
566func finalizeDownloadResponse(
567 response *http.Response,

Callers 1

DownloadMethod · 0.95

Calls 2

doRequestMethod · 0.95
firstNonEmptyFunction · 0.70

Tested by

no test coverage detected