Merge pull request #8063 from jlhawn/tarsum_empty_tar_archive

tarsum: correct close and finish reads
This commit is contained in:
Vincent Batts 2014-09-16 15:41:28 -04:00
commit e32fdc563a
2 changed files with 80 additions and 0 deletions

View file

@ -162,6 +162,12 @@ func (ts *tarSum) Read(buf []byte) (int, error) {
currentHeader, err := ts.tarR.Next()
if err != nil {
if err == io.EOF {
if err := ts.tarW.Close(); err != nil {
return 0, err
}
if _, err := io.Copy(ts.gz, ts.bufTar); err != nil {
return 0, err
}
if err := ts.gz.Close(); err != nil {
return 0, err
}