aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/object/blob.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-05-04 01:45:11 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-05-04 01:45:11 +0200
commitff18ce3751ad80cfd0297845872ba1d796c36ca5 (patch)
tree0b0a72f26482bc61bad7258d10a9a2d1392d2b90 /plumbing/object/blob.go
parent5592dabdf9eed67c92b0e411ad375ae763119fd2 (diff)
downloadgo-git-ff18ce3751ad80cfd0297845872ba1d796c36ca5.tar.gz
plumbing: MemoryObject.Writer tracks his own size
Diffstat (limited to 'plumbing/object/blob.go')
-rw-r--r--plumbing/object/blob.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/plumbing/object/blob.go b/plumbing/object/blob.go
index 2771416..2608477 100644
--- a/plumbing/object/blob.go
+++ b/plumbing/object/blob.go
@@ -68,18 +68,23 @@ func (b *Blob) Decode(o plumbing.EncodedObject) error {
// Encode transforms a Blob into a plumbing.EncodedObject.
func (b *Blob) Encode(o plumbing.EncodedObject) error {
+ o.SetType(plumbing.BlobObject)
+
w, err := o.Writer()
if err != nil {
return err
}
+
defer ioutil.CheckClose(w, &err)
+
r, err := b.Reader()
if err != nil {
return err
}
+
defer ioutil.CheckClose(r, &err)
+
_, err = io.Copy(w, r)
- o.SetType(plumbing.BlobObject)
return err
}