Commit 861f30cc authored by Jeromy's avatar Jeromy

don't readd entire directories recursively

parent d7c91992
......@@ -232,15 +232,6 @@ func add(n *core.IpfsNode, readers []io.Reader) ([]*dag.Node, error) {
return dagnodes, nil
}
func addNode(n *core.IpfsNode, node *dag.Node) error {
err := n.DAG.AddRecursive(node) // add the file to the graph + local storage
if err != nil {
return err
}
return nil
}
func addFile(n *core.IpfsNode, file files.File, out chan interface{}, progress bool, wrap bool) (*dag.Node, error) {
if file.IsDirectory() {
return addDir(n, file, out, progress)
......@@ -309,7 +300,7 @@ func addDir(n *core.IpfsNode, dir files.File, out chan interface{}, progress boo
return nil, err
}
err = addNode(n, tree)
_, err = n.DAG.Add(tree)
if err != nil {
return nil, err
}
......
......@@ -384,13 +384,8 @@ var ErrEmptyNode = errors.New("no data or links in this node")
// objectPut takes a format option, serializes bytes from stdin and updates the dag with that data
func objectPut(n *core.IpfsNode, input io.Reader, encoding string) (*Object, error) {
var (
dagnode *dag.Node
data []byte
err error
)
data, err = ioutil.ReadAll(io.LimitReader(input, inputLimit+10))
data, err := ioutil.ReadAll(io.LimitReader(input, inputLimit+10))
if err != nil {
return nil, err
}
......@@ -399,6 +394,7 @@ func objectPut(n *core.IpfsNode, input io.Reader, encoding string) (*Object, err
return nil, ErrObjectTooLarge
}
var dagnode *dag.Node
switch getObjectEnc(encoding) {
case objectEncodingJSON:
node := new(Node)
......@@ -429,7 +425,7 @@ func objectPut(n *core.IpfsNode, input io.Reader, encoding string) (*Object, err
return nil, err
}
err = addNode(n, dagnode)
_, err = n.DAG.Add(dagnode)
if err != nil {
return nil, err
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment