Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
Use CopyBuffer in writeTar (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjohnsonjr authored Jul 11, 2023
1 parent 57105dd commit 2a13d9f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/tarball/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ func (c *Context) writeTar(ctx context.Context, tw *tar.Writer, fsys fs.FS, user
c.overridePerms = map[string]tar.Header{}
}

buf := make([]byte, 1<<20)

if err := fs.WalkDir(fsys, ".", func(path string, d fs.DirEntry, err error) error {
if err := ctx.Err(); err != nil {
return err
Expand Down Expand Up @@ -253,7 +255,7 @@ func (c *Context) writeTar(ctx context.Context, tw *tar.Writer, fsys fs.FS, user

defer data.Close()

if _, err := io.Copy(tw, data); err != nil {
if _, err := io.CopyBuffer(tw, data, buf); err != nil {
return err
}
}
Expand Down

0 comments on commit 2a13d9f

Please sign in to comment.