Skip to content

Commit

Permalink
Merge pull request #1772 from giuseppe/fix-diffid-zstd-chunked
Browse files Browse the repository at this point in the history
chunked: flush the input tarball to the output
  • Loading branch information
openshift-merge-bot[bot] authored Dec 13, 2023
2 parents 74199b4 + 6a7ab2b commit 1a86024
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pkg/chunked/compressor/compressor.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,14 @@ func writeZstdChunkedStream(destFile io.Writer, outMetadata map[string]string, r
zstdWriter.Close()
return err
}

// make sure the entire tarball is flushed to the output as it might contain
// some trailing zeros that affect the checksum.
if _, err := io.Copy(zstdWriter, its); err != nil {
zstdWriter.Close()
return err
}

if err := zstdWriter.Flush(); err != nil {
zstdWriter.Close()
return err
Expand Down Expand Up @@ -452,12 +460,12 @@ type zstdChunkedWriter struct {
}

func (w zstdChunkedWriter) Close() error {
err := <-w.tarSplitErr
if err != nil {
w.tarSplitOut.Close()
errClose := w.tarSplitOut.Close()

if err := <-w.tarSplitErr; err != nil && err != io.EOF {
return err
}
return w.tarSplitOut.Close()
return errClose
}

func (w zstdChunkedWriter) Write(p []byte) (int, error) {
Expand Down

0 comments on commit 1a86024

Please sign in to comment.