Skip to content

fix: Add DownloadContent to support downloads of any size - #3818

Closed
sheeeng wants to merge 3 commits into
google:masterfrom
sheeeng:fix/download-contents
Closed

fix: Add DownloadContent to support downloads of any size#3818
sheeeng wants to merge 3 commits into
google:masterfrom
sheeeng:fix/download-contents

Conversation

@sheeeng

@sheeengsheeeng commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

Fix#3810.
Fix#2480.

Fixgoogle#3810.
Fixgoogle#2480.
Signed-off-by: Leonard Sheng Sheng Lee <leonard.sheng.sheng.lee@gmail.com>
@sheeeng
sheeengforce-pushed the fix/download-contents branch from 36cde08 to 79cf23aCompareNovember 10, 2025 16:48
@gmlewisgmlewis changed the title fix: download contentsfix: Add DownloadContent to support downloads of any sizeNov 10, 2025

@gmlewisgmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My biggest concern is that we now have:

  • DownloadContent
  • DownloadContents
  • DownloadContentsWithMeta
  • GetContent
  • GetContents

How is a user supposed to understand which one to choose?

@sheeeng
sheeeng marked this pull request as draft November 10, 2025 16:52
@sheeeng

Copy link
Copy Markdown
ContributorAuthor

My biggest concern is that we now have:

  • DownloadContent
  • DownloadContents
  • DownloadContentsWithMeta
  • GetContent
  • GetContents

How is a user supposed to understand which one to choose?

Good point. I will think about it.

Fixgoogle#3810.
Fixgoogle#2480.
Signed-off-by: Leonard Sheng Sheng Lee <leonard.sheng.sheng.lee@gmail.com>
@sheeeng
sheeeng marked this pull request as ready for review November 10, 2025 17:22
@sheeeng

Copy link
Copy Markdown
ContributorAuthor
  • DownloadContents
  • DownloadContentsWithMeta

These two are existing functions. Do we want to expose DownloadContents only for use?

Delete DownloadContentsWithMeta function and its references.
Signed-off-by: Leonard Sheng Sheng Lee <leonard.sheng.sheng.lee@gmail.com>
@sheeeng

sheeeng commented Nov 10, 2025

Copy link
Copy Markdown
ContributorAuthor

Do we want to expose DownloadContents only for use?

The DownloadContentsWithMeta function and its references were deleted. Is that preferred?

@gmlewis

Copy link
Copy Markdown
Collaborator

The DownloadContentsWithMeta function and its references were deleted. Is that preferred?

Well, it seems we have a number of people interested in this topic based on the conversation in #2480 and #3810.

I would really like to get some feedback from the individuals who care about these endpoints before we start changing it dramatically, and the only way I can think of doing that is to start listing GitHub logins that commented, unfortunately.

cc: Please provide your feedback on how these endpoints should be handled:

@gmlewisgmlewis added waiting for reply NeedsDecision NeedsReview PR is awaiting a review before merging. labels Nov 10, 2025
@ran-arigur

Copy link
Copy Markdown

My biggest concern is that we now have:

  • DownloadContent
  • DownloadContents
  • DownloadContentsWithMeta
  • GetContent
  • GetContents

How is a user supposed to understand which one to choose?

(Full disclosure: Adding DownloadContent was my suggestion, so I can't independently say whether it will make sense to other people.)

FWIW, those methods are not all on the same type. Grouping it a bit differently:

  • on RepositoriesService:
    • GetContents(...)
      • is genuinely a bit confusing, but I don't think we should change it, because it maps pretty directly to an underlying API call [doc link] and what makes it confusing is that that API is confusing.
      • returns either a single RepositoryContent or a slice of RepositoryContents, depending on whether the path is a file or a directory.
    • DownloadContents(...), DownloadContentsWithMeta(...)
      • convenience wrappers around GetContents(...) + DownloadContent().
      • behave identically, but DownloadContentsWithMeta(...) returns more information. I assume that DownloadContents(...) was created first, and then DownloadContentsWithMeta(...) was added later because there was no backward-compatible way to have DownloadContents(...) return the additional information.
  • on RepositoryContent (as returned by RepositoriesService.GetContents(...)):
    • GetContent()
      • returns the file content, if already available on the RepositoryContent. handles Base64-decoding if necessary.
      • doesn't handle cases where the RepositoryContent doesn't contain the file content, e.g. if the file is >1MB (in which case it returns an error) or the RepositoryContent came from listing a directory (in which case it returns the empty string even if the file is non-empty).
    • DownloadContent()
      • equivalent to GetContent(), except that it works even if the RepositoryContent doesn't contain the file content: in that case it fetches it using the RepositoryContent's DownloadURL.

I think that, with reasonable comments on each, users will be able to find a method that does what they need, and ignore the rest.

@sheeeng
sheeeng marked this pull request as draft December 4, 2025 13:42
@sheeeng

Copy link
Copy Markdown
ContributorAuthor

Setting this PR as draft as waiting for more feedback.

@gmlewis

Copy link
Copy Markdown
Collaborator

Closing, as this was resolved by #4153.

@gmlewisgmlewis closed this May 21, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NeedsDecisionNeedsReviewPR is awaiting a review before merging.waiting for reply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DownloadContents can't always download files in large directories DownloadContents can't download files from root of repo

3 participants

@sheeeng@gmlewis@ran-arigur