swarm/api: close tar writer in GetDirectoryTar to flush and clean (#17339)

This commit is contained in:
Janoš Guljaš 2018-08-09 16:15:07 +02:00 committed by Balint Gabor
parent d3e4c2dcb0
commit 3bcb501c8f
1 changed files with 4 additions and 0 deletions

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)