Skip to content

Commit

Permalink
Merge pull request #793 from jonjohnsonjr/bufio
Browse files Browse the repository at this point in the history
  • Loading branch information
imjasonh authored Jul 8, 2023
2 parents 68e80b9 + 4068d56 commit eabf68b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/build/build_implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package build

import (
"bufio"
"context"
"crypto/sha256"
"errors"
Expand Down Expand Up @@ -99,7 +100,8 @@ func (di *buildImplementation) BuildTarball(ctx context.Context, o *options.Opti

digest := sha256.New()

gzw := gzip.NewWriter(io.MultiWriter(digest, outfile))
buf := bufio.NewWriterSize(outfile, 1<<22)
gzw := gzip.NewWriter(io.MultiWriter(digest, buf))

diffid := sha256.New()

Expand All @@ -110,6 +112,10 @@ func (di *buildImplementation) BuildTarball(ctx context.Context, o *options.Opti
return "", nil, nil, 0, fmt.Errorf("closing gzip writer: %w", err)
}

if err := buf.Flush(); err != nil {
return "", nil, nil, 0, fmt.Errorf("flushing %s: %w", outfile.Name(), err)
}

stat, err := outfile.Stat()
if err != nil {
return "", nil, nil, 0, fmt.Errorf("stat(%q): %w", outfile.Name(), err)
Expand Down

0 comments on commit eabf68b

Please sign in to comment.