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
62d23c06
Commit
62d23c06
authored
Jan 24, 2017
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
skip putting blocks we already have
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
e12adeca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
filestore/filestore.go
filestore/filestore.go
+18
-0
No files found.
filestore/filestore.go
View file @
62d23c06
...
...
@@ -129,6 +129,15 @@ func (f *Filestore) Has(c *cid.Cid) (bool, error) {
}
func
(
f
*
Filestore
)
Put
(
b
blocks
.
Block
)
error
{
has
,
err
:=
f
.
Has
(
b
.
Cid
())
if
err
!=
nil
{
return
err
}
if
has
{
return
nil
}
switch
b
:=
b
.
(
type
)
{
case
*
posinfo
.
FilestoreNode
:
return
f
.
fm
.
Put
(
b
)
...
...
@@ -142,6 +151,15 @@ func (f *Filestore) PutMany(bs []blocks.Block) error {
var
fstores
[]
*
posinfo
.
FilestoreNode
for
_
,
b
:=
range
bs
{
has
,
err
:=
f
.
Has
(
b
.
Cid
())
if
err
!=
nil
{
return
err
}
if
has
{
continue
}
switch
b
:=
b
.
(
type
)
{
case
*
posinfo
.
FilestoreNode
:
fstores
=
append
(
fstores
,
b
)
...
...
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