Skip to content

Conversation

@sheeeng
Copy link
Contributor

@sheeeng sheeeng commented Nov 10, 2025

Fix #3810.
Fix #2480.

Fix google#3810.
Fix google#2480.

Signed-off-by: Leonard Sheng Sheng Lee <leonard.sheng.sheng.lee@gmail.com>
@sheeeng sheeeng force-pushed the fix/download-contents branch from 36cde08 to 79cf23a Compare November 10, 2025 16:48
@gmlewis gmlewis changed the title fix: download contents fix: Add DownloadContent to support downloads of any size Nov 10, 2025
Copy link
Collaborator

@gmlewis gmlewis left a comment

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
Contributor Author

sheeeng commented Nov 10, 2025

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.

Fix google#3810.
Fix google#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
Contributor Author

sheeeng commented Nov 10, 2025

  • 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
Copy link
Contributor Author

sheeeng commented Nov 10, 2025

Do we want to expose DownloadContents only for use?

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

@gmlewis
Copy link
Collaborator

gmlewis commented Nov 10, 2025

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:

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NeedsDecision NeedsReview PR 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