From c29514f19a39f39d18d575051a96e858a821c639 Mon Sep 17 00:00:00 2001 From: Nicholas Herring Date: Sun, 9 Jun 2024 00:13:57 +0000 Subject: [PATCH] fix: propagate context with DownloadContents Main motivation is tracing as this can be the most time consuming operation. --- github/repos_contents.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/github/repos_contents.go b/github/repos_contents.go index c4453739f9c..97539aeeb5e 100644 --- a/github/repos_contents.go +++ b/github/repos_contents.go @@ -150,7 +150,11 @@ func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo, return nil, resp, fmt.Errorf("no download link found for %s", filepath) } - dlResp, err := s.client.client.Get(*contents.DownloadURL) + dlReq, err := http.NewRequestWithContext(ctx, http.MethodGet, *contents.DownloadURL, nil) + if err != nil { + return nil, resp, err + } + dlResp, err := s.client.client.Do(dlReq) if err != nil { return nil, &Response{Response: dlResp}, err } @@ -188,7 +192,11 @@ func (s *RepositoriesService) DownloadContentsWithMeta(ctx context.Context, owne return nil, contents, resp, fmt.Errorf("no download link found for %s", filepath) } - dlResp, err := s.client.client.Get(*contents.DownloadURL) + dlReq, err := http.NewRequestWithContext(ctx, http.MethodGet, *contents.DownloadURL, nil) + if err != nil { + return nil, contents, resp, err + } + dlResp, err := s.client.client.Do(dlReq) if err != nil { return nil, contents, &Response{Response: dlResp}, err }