Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
96269e02
Commit
96269e02
authored
Feb 09, 2017
by
Kevin Atkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filestore: Refactor.
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
parent
81af0347
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
9 deletions
+7
-9
filestore/fsrefstore.go
filestore/fsrefstore.go
+4
-0
filestore/util.go
filestore/util.go
+3
-9
No files found.
filestore/fsrefstore.go
View file @
96269e02
...
...
@@ -109,6 +109,10 @@ func (f *FileManager) getDataObj(c *cid.Cid) (*pb.DataObj, error) {
//
}
return
unmarshalDataObj
(
o
)
}
func
unmarshalDataObj
(
o
interface
{})
(
*
pb
.
DataObj
,
error
)
{
data
,
ok
:=
o
.
([]
byte
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"stored filestore dataobj was not a []byte"
)
...
...
filestore/util.go
View file @
96269e02
...
...
@@ -9,7 +9,6 @@ import (
ds
"gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore"
dsq
"gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore/query"
proto
"gx/ipfs/QmT6n4mspWYEya864BhCUJEgyxiRfmiSY9ruQwTUNpRKaM/protobuf/proto"
cid
"gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid"
)
...
...
@@ -124,17 +123,12 @@ func next(qr dsq.Results) (*cid.Cid, *pb.DataObj, error) {
return
nil
,
nil
,
fmt
.
Errorf
(
"decoding cid from filestore: %s"
,
err
)
}
data
,
ok
:=
v
.
Value
.
([]
byte
)
if
!
ok
{
return
c
,
nil
,
fmt
.
Errorf
(
"stored filestore dataobj was not a []byte"
)
}
var
dobj
pb
.
DataObj
if
err
:=
proto
.
Unmarshal
(
data
,
&
dobj
);
err
!=
nil
{
dobj
,
err
:=
unmarshalDataObj
(
v
.
Value
)
if
err
!=
nil
{
return
c
,
nil
,
err
}
return
c
,
&
dobj
,
nil
return
c
,
dobj
,
nil
}
func
mkListRes
(
c
*
cid
.
Cid
,
d
*
pb
.
DataObj
,
err
error
)
*
ListRes
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment