aboutsummaryrefslogtreecommitdiffstats
path: root/formats/packfile/reader.go
diff options
context:
space:
mode:
authorJoshua Sjoding <joshua.sjoding@scjalliance.com>2016-02-16 03:28:21 -0800
committerJoshua Sjoding <joshua.sjoding@scjalliance.com>2016-02-16 03:28:21 -0800
commite82d4918b403a641a5295b3f199586b0ab26b15c (patch)
tree7b16fa8616393ed911824ff5155f40f1b9c38716 /formats/packfile/reader.go
parent45478768e1fa49030b574aec13390fb2d9479836 (diff)
downloadgo-git-e82d4918b403a641a5295b3f199586b0ab26b15c.tar.gz
Functions in core.ObjectStorage interface now return an error
Diffstat (limited to 'formats/packfile/reader.go')
-rw-r--r--formats/packfile/reader.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/formats/packfile/reader.go b/formats/packfile/reader.go
index 959e411..91aef21 100644
--- a/formats/packfile/reader.go
+++ b/formats/packfile/reader.go
@@ -144,7 +144,10 @@ func (r *Reader) readObjects(count uint32) error {
}
func (r *Reader) newRAWObject() (core.Object, error) {
- raw := r.s.New()
+ raw, err := r.s.New()
+ if err != nil {
+ return nil, err
+ }
var steps int64
var buf [1]byte
@@ -170,7 +173,6 @@ func (r *Reader) newRAWObject() (core.Object, error) {
raw.SetType(typ)
raw.SetSize(size)
- var err error
switch raw.Type() {
case core.REFDeltaObject:
err = r.readREFDelta(raw)
@@ -196,9 +198,12 @@ func (r *Reader) readREFDelta(raw core.Object) error {
return err
}
- referenced, ok := r.s.Get(ref)
- if !ok {
- return ObjectNotFoundErr.n("%s", ref)
+ referenced, err := r.s.Get(ref)
+ if err != nil {
+ if err == core.ObjectNotFoundErr {
+ return ObjectNotFoundErr.n("%s", ref)
+ }
+ return err
}
d, _ := ioutil.ReadAll(referenced.Reader())
@@ -231,7 +236,7 @@ func (r *Reader) readOFSDelta(raw core.Object, steps int64) error {
return PackEntryNotFoundErr.n("offset %d", start+offset)
}
- referenced, _ := r.s.Get(ref)
+ referenced, _ := r.s.Get(ref) // FIXME: Handle error returned from Get()
d, _ := ioutil.ReadAll(referenced.Reader())
patched := patchDelta(d, buf.Bytes())
if patched == nil {