aboutsummaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2020-05-24 19:25:08 +0200
committerGitHub <noreply@github.com>2020-05-24 19:25:08 +0200
commit8019144b6534ff58ad234a355e5b143f1c99b45e (patch)
tree5a67682c34bb20a826ebf430f11181d6892fc0e7 /storage
parente7f544844d6d736acfd9d75ee0d4a9d37f450103 (diff)
parent10199949b9e5a71f72241c4bb23f3d733287065c (diff)
downloadgo-git-8019144b6534ff58ad234a355e5b143f1c99b45e.tar.gz
Merge pull request #73 from WKBae/close_objectv5.1.0
Close Reader & Writer of EncodedObject after use
Diffstat (limited to 'storage')
-rw-r--r--storage/filesystem/object.go2
-rw-r--r--storage/test/storage_suite.go14
2 files changed, 14 insertions, 2 deletions
diff --git a/storage/filesystem/object.go b/storage/filesystem/object.go
index 862cc1b..7437174 100644
--- a/storage/filesystem/object.go
+++ b/storage/filesystem/object.go
@@ -408,6 +408,8 @@ func (s *ObjectStorage) getFromUnpacked(h plumbing.Hash) (obj plumbing.EncodedOb
return nil, err
}
+ defer ioutil.CheckClose(w, &err)
+
s.objectCache.Put(obj)
_, err = io.Copy(w, r)
diff --git a/storage/test/storage_suite.go b/storage/test/storage_suite.go
index d87a7dd..2c00e75 100644
--- a/storage/test/storage_suite.go
+++ b/storage/test/storage_suite.go
@@ -494,12 +494,12 @@ func objectEquals(a plumbing.EncodedObject, b plumbing.EncodedObject) error {
ra, err := a.Reader()
if err != nil {
- return fmt.Errorf("can't get reader on b: %q", err)
+ return fmt.Errorf("can't get reader on a: %q", err)
}
rb, err := b.Reader()
if err != nil {
- return fmt.Errorf("can't get reader on a: %q", err)
+ return fmt.Errorf("can't get reader on b: %q", err)
}
ca, err := ioutil.ReadAll(ra)
@@ -516,5 +516,15 @@ func objectEquals(a plumbing.EncodedObject, b plumbing.EncodedObject) error {
return errors.New("content does not match")
}
+ err = rb.Close()
+ if err != nil {
+ return fmt.Errorf("can't close reader on b: %q", err)
+ }
+
+ err = ra.Close()
+ if err != nil {
+ return fmt.Errorf("can't close reader on a: %q", err)
+ }
+
return nil
}