diff options
author | Kyungmin Bae <kyungmin.bae@devsisters.com> | 2020-05-24 02:29:58 +0900 |
---|---|---|
committer | Kyungmin Bae <kyungmin.bae@devsisters.com> | 2020-05-24 02:29:58 +0900 |
commit | 10199949b9e5a71f72241c4bb23f3d733287065c (patch) | |
tree | 52b3efdb1944d9c833522d32a0af5c4b275a3ab6 /plumbing/format/packfile/encoder.go | |
parent | 6d8103df45ce09ffd5323b4ef46d26440400a54f (diff) | |
download | go-git-10199949b9e5a71f72241c4bb23f3d733287065c.tar.gz |
Close Reader & Writer of EncodedObject after use
Diffstat (limited to 'plumbing/format/packfile/encoder.go')
-rw-r--r-- | plumbing/format/packfile/encoder.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/plumbing/format/packfile/encoder.go b/plumbing/format/packfile/encoder.go index 65fae52..5501f88 100644 --- a/plumbing/format/packfile/encoder.go +++ b/plumbing/format/packfile/encoder.go @@ -9,6 +9,7 @@ import ( "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/storer" "github.com/go-git/go-git/v5/utils/binary" + "github.com/go-git/go-git/v5/utils/ioutil" ) // Encoder gets the data from the storage and write it into the writer in PACK @@ -80,7 +81,7 @@ func (e *Encoder) head(numEntries int) error { ) } -func (e *Encoder) entry(o *ObjectToPack) error { +func (e *Encoder) entry(o *ObjectToPack) (err error) { if o.WantWrite() { // A cycle exists in this delta chain. This should only occur if a // selected object representation disappeared during writing @@ -119,17 +120,22 @@ func (e *Encoder) entry(o *ObjectToPack) error { } e.zw.Reset(e.w) + + defer ioutil.CheckClose(e.zw, &err) + or, err := o.Object.Reader() if err != nil { return err } + defer ioutil.CheckClose(or, &err) + _, err = io.Copy(e.zw, or) if err != nil { return err } - return e.zw.Close() + return nil } func (e *Encoder) writeBaseIfDelta(o *ObjectToPack) error { |