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
b204c21d
Commit
b204c21d
authored
Oct 13, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add plumbing output + logging
Fixes #157 Found #158
parent
cb15a437
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
17 deletions
+16
-17
core/commands/add.go
core/commands/add.go
+15
-17
merkledag/merkledag.go
merkledag/merkledag.go
+1
-0
No files found.
core/commands/add.go
View file @
b204c21d
...
...
@@ -38,14 +38,6 @@ func Add(n *core.IpfsNode, args []string, opts map[string]interface{}, out io.Wr
return
fmt
.
Errorf
(
"addFile error: %v"
,
err
)
}
// get the key to print it
// k, err := nd.Key()
// if err != nil {
// return fmt.Errorf("addFile error: %v", err)
// }
//
// Commenting out of here, because it's already in addNode below.
// fmt.Fprintf(out, "added %s %s\n", k, path)
}
return
nil
}
...
...
@@ -89,7 +81,9 @@ func addDir(n *core.IpfsNode, fpath string, depth int, out io.Writer) (*dag.Node
}
}
return
tree
,
addNode
(
n
,
tree
,
fpath
)
log
.
Info
(
"adding dir: %s"
,
fpath
)
return
tree
,
addNode
(
n
,
tree
,
fpath
,
out
)
}
func
addFile
(
n
*
core
.
IpfsNode
,
fpath
string
,
depth
int
,
out
io
.
Writer
)
(
*
dag
.
Node
,
error
)
{
...
...
@@ -98,27 +92,31 @@ func addFile(n *core.IpfsNode, fpath string, depth int, out io.Writer) (*dag.Nod
return
nil
,
err
}
k
,
err
:=
root
.
Key
()
if
err
!=
nil
{
return
nil
,
err
}
log
.
Info
(
"adding file: %s"
,
fpath
)
fmt
.
Fprintf
(
out
,
"Adding file: %s = %s
\n
"
,
fpath
,
k
)
for
_
,
l
:=
range
root
.
Links
{
fmt
.
Fprintf
(
out
,
"S
ub
B
lock: %s
\n
"
,
l
.
Hash
.
B58String
())
log
.
Info
(
"adding s
ub
b
lock: %s
%s"
,
l
.
Name
,
l
.
Hash
.
B58String
())
}
return
root
,
addNode
(
n
,
root
,
fpath
)
return
root
,
addNode
(
n
,
root
,
fpath
,
out
)
}
// addNode adds the node to the graph + local storage
func
addNode
(
n
*
core
.
IpfsNode
,
nd
*
dag
.
Node
,
fpath
string
)
error
{
func
addNode
(
n
*
core
.
IpfsNode
,
nd
*
dag
.
Node
,
fpath
string
,
out
io
.
Writer
)
error
{
// add the file to the graph + local storage
err
:=
n
.
DAG
.
AddRecursive
(
nd
)
if
err
!=
nil
{
return
err
}
k
,
err
:=
nd
.
Key
()
if
err
!=
nil
{
return
err
}
// output that we've added this node
fmt
.
Fprintf
(
out
,
"added %s %s
\n
"
,
k
,
fpath
)
// ensure we keep it. atm no-op
return
n
.
PinDagNodeRecursively
(
nd
,
-
1
)
}
merkledag/merkledag.go
View file @
b204c21d
...
...
@@ -124,6 +124,7 @@ func (n *Node) Size() (uint64, error) {
// Multihash hashes the encoded data of this node.
func
(
n
*
Node
)
Multihash
()
(
mh
.
Multihash
,
error
)
{
// Note: Encoded generates the hash and puts it in n.cached.
_
,
err
:=
n
.
Encoded
(
false
)
if
err
!=
nil
{
return
nil
,
err
...
...
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