GetArchive should return an io.ReadCloser #475

Closed
opened 2021-01-15 10:44:56 +00:00 by petergardfjall · 0 comments
Contributor

The GetArchive call appears to be designed with very small repositories in mind, since it returns the entire archive zip/tar.gz in the client's memory. For larger repositories this appears both infeasible (risking to blow up the client memory-wise) and very non-idiomatic (for Go code).

The natural choice (IMHO) would have been to return an io.ReadCloser since I figure that the common thing is for the client to stream the archive to a file on disk (or similar) before processing it. Anyway, an io.ReadCloser that reads the response body content would be endlessly more flexible.

So instead of:

func (c *Client) GetArchive(owner, repo, ref string, ext ArchiveType) ([]byte, *Response, error)

it would be nice to have something like:

func (c *Client) GetArchive(owner, repo, ref string, ext ArchiveType) (io.ReadCloser, error)

If backwards-compatibility is a concern maybe introduce a new method:

func (c *Client) GetArchiveReader(owner, repo, ref string, ext ArchiveType) (io.ReadCloser, error)
The `GetArchive` call appears to be designed with very small repositories in mind, since it returns the entire archive zip/tar.gz in the client's memory. For larger repositories this appears both infeasible (risking to blow up the client memory-wise) and very non-idiomatic (for Go code). The natural choice (IMHO) would have been to return an `io.ReadCloser` since I figure that the common thing is for the client to stream the archive to a file on disk (or similar) before processing it. Anyway, an `io.ReadCloser` that reads the response body content would be endlessly more flexible. So instead of: ``` func (c *Client) GetArchive(owner, repo, ref string, ext ArchiveType) ([]byte, *Response, error) ``` it would be nice to have something like: ``` func (c *Client) GetArchive(owner, repo, ref string, ext ArchiveType) (io.ReadCloser, error) ``` If backwards-compatibility is a concern maybe introduce a new method: ``` func (c *Client) GetArchiveReader(owner, repo, ref string, ext ArchiveType) (io.ReadCloser, error) ```
6543 added the
has/pull
kind/proposal
labels 2021-01-15 14:42:15 +00:00
6543 referenced this issue from a commit 2021-01-17 17:14:08 +00:00
6543 closed this issue 2021-01-17 17:14:08 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gitea/go-sdk#475
No description provided.