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-unixfs
Commits
bdef3a1f
Commit
bdef3a1f
authored
Oct 30, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrite add command to use dagwriter, moved a pinner into the dagwriter for inline pinning
parent
b73ce6e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
io/dagwriter.go
io/dagwriter.go
+10
-2
No files found.
io/dagwriter.go
View file @
bdef3a1f
...
...
@@ -3,6 +3,7 @@ package io
import
(
"github.com/jbenet/go-ipfs/importer/chunk"
dag
"github.com/jbenet/go-ipfs/merkledag"
"github.com/jbenet/go-ipfs/pin"
ft
"github.com/jbenet/go-ipfs/unixfs"
"github.com/jbenet/go-ipfs/util"
)
...
...
@@ -17,6 +18,7 @@ type DagWriter struct {
done
chan
struct
{}
splitter
chunk
.
BlockSplitter
seterr
error
Pinner
pin
.
ManualPinner
}
func
NewDagWriter
(
ds
dag
.
DAGService
,
splitter
chunk
.
BlockSplitter
)
*
DagWriter
{
...
...
@@ -48,7 +50,10 @@ func (dw *DagWriter) startSplitter() {
// Store the block size in the root node
mbf
.
AddBlockSize
(
uint64
(
len
(
blkData
)))
node
:=
&
dag
.
Node
{
Data
:
ft
.
WrapData
(
blkData
)}
_
,
err
:=
dw
.
dagserv
.
Add
(
node
)
nk
,
err
:=
dw
.
dagserv
.
Add
(
node
)
if
dw
.
Pinner
!=
nil
{
dw
.
Pinner
.
PinWithMode
(
nk
,
pin
.
Indirect
)
}
if
err
!=
nil
{
dw
.
seterr
=
err
log
.
Critical
(
"Got error adding created node to dagservice: %s"
,
err
)
...
...
@@ -75,12 +80,15 @@ func (dw *DagWriter) startSplitter() {
root
.
Data
=
data
// Add root node to the dagservice
_
,
err
=
dw
.
dagserv
.
Add
(
root
)
rootk
,
err
:
=
dw
.
dagserv
.
Add
(
root
)
if
err
!=
nil
{
dw
.
seterr
=
err
log
.
Critical
(
"Got error adding created node to dagservice: %s"
,
err
)
return
}
if
dw
.
Pinner
!=
nil
{
dw
.
Pinner
.
PinWithMode
(
rootk
,
pin
.
Recursive
)
}
dw
.
node
=
root
dw
.
done
<-
struct
{}{}
}
...
...
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