Skip to content

Commit

Permalink
Merge pull request #4807 from AkihiroSuda/fix-4805
Browse files Browse the repository at this point in the history
util/converter: fix diffID computation
  • Loading branch information
AkihiroSuda authored Apr 2, 2024
2 parents cf2053e + e315f0e commit cbb116d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion util/converter/tarconverter/tarconverter.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
type HeaderConverter func(*tar.Header)

// NewReader returns a reader that applies headerConverter.
// srcContent is drained until hitting EOF.
// Forked from https://github.com/moby/moby/blob/v24.0.6/pkg/archive/copy.go#L308-L373 .
func NewReader(srcContent io.Reader, headerConverter HeaderConverter) io.ReadCloser {
rebased, w := io.Pipe()
Expand All @@ -21,7 +22,14 @@ func NewReader(srcContent io.Reader, headerConverter HeaderConverter) io.ReadClo
if err == io.EOF {
// Signals end of archive.
rebasedTar.Close()
w.Close()
// drain the reader into io.Discard, until hitting EOF
// https://github.com/moby/buildkit/pull/4807#discussion_r1544621787
_, err = io.Copy(io.Discard, srcContent)
if err != nil {
w.CloseWithError(err)
} else {
w.Close()
}
return
}
if err != nil {
Expand Down

0 comments on commit cbb116d

Please sign in to comment.