swarm/api: close tar writer in GetDirectoryTar to flush and clean

This commit is contained in:
Janos Guljas 2018-08-07 15:35:04 +02:00
parent 4bb2dc3d09
commit 359238c5dc

View file

@ -525,6 +525,10 @@ func (a *API) GetDirectoryTar(ctx context.Context, uri *URI) (io.ReadCloser, err
return nil
})
// close tar writer before closing pipew
// to flush remaining data to pipew
// regardless of error value
tw.Close()
if err != nil {
apiGetTarFail.Inc(1)
pipew.CloseWithError(err)