Skip to content

Commit 10e2401

Browse files
committed
Refactor.
License: MIT Signed-off-by: Kevin Atkinson <[email protected]>
1 parent c179b4d commit 10e2401

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

filestore/fsrefstore.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ func (f *FileManager) getDataObj(c *cid.Cid) (*pb.DataObj, error) {
109109
//
110110
}
111111

112+
return unmarshalDataObj(o)
113+
}
114+
115+
func unmarshalDataObj(o interface{}) (*pb.DataObj, error) {
112116
data, ok := o.([]byte)
113117
if !ok {
114118
return nil, fmt.Errorf("stored filestore dataobj was not a []byte")

filestore/util.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
ds "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore"
1111
dsq "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore/query"
12-
proto "gx/ipfs/QmT6n4mspWYEya864BhCUJEgyxiRfmiSY9ruQwTUNpRKaM/protobuf/proto"
1312
cid "gx/ipfs/QmcTcsTvfaeEBRFo1TkFgT8sRmgi1n1LTZpecfVP8fzpGD/go-cid"
1413
)
1514

@@ -124,17 +123,12 @@ func next(qr dsq.Results) (*cid.Cid, *pb.DataObj, error) {
124123
return nil, nil, fmt.Errorf("decoding cid from filestore: %s", err)
125124
}
126125

127-
data, ok := v.Value.([]byte)
128-
if !ok {
129-
return c, nil, fmt.Errorf("stored filestore dataobj was not a []byte")
130-
}
131-
132-
var dobj pb.DataObj
133-
if err := proto.Unmarshal(data, &dobj); err != nil {
126+
dobj, err := unmarshalDataObj(v.Value)
127+
if err != nil {
134128
return c, nil, err
135129
}
136130

137-
return c, &dobj, nil
131+
return c, dobj, nil
138132
}
139133

140134
func mkListRes(c *cid.Cid, d *pb.DataObj, err error) *ListRes {

0 commit comments

Comments
 (0)