mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-22 10:57:42 +08:00
object-patch: Support linking to non-dagpb objects
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
parent
bbdbd0ac6f
commit
9aab19ea35
@ -325,13 +325,7 @@ to a file containing 'bar', and returns the hash of the new object.
|
||||
return
|
||||
}
|
||||
|
||||
chpb, ok := childnd.(*dag.ProtoNode)
|
||||
if !ok {
|
||||
res.SetError(dag.ErrNotProtobuf, cmdkit.ErrNormal)
|
||||
return
|
||||
}
|
||||
|
||||
err = e.InsertNodeAtPath(req.Context(), npath, chpb, createfunc)
|
||||
err = e.InsertNodeAtPath(req.Context(), npath, childnd, createfunc)
|
||||
if err != nil {
|
||||
res.SetError(err, cmdkit.ErrNormal)
|
||||
return
|
||||
|
||||
@ -212,8 +212,9 @@ func copyDag(nd *dag.ProtoNode, from, to dag.DAGService) error {
|
||||
}
|
||||
|
||||
childpb, ok := child.(*dag.ProtoNode)
|
||||
if !ok {
|
||||
return dag.ErrNotProtobuf
|
||||
if !ok { // leaf node
|
||||
_, err := to.Add(nd)
|
||||
return err
|
||||
}
|
||||
|
||||
err = copyDag(childpb, from, to)
|
||||
|
||||
@ -216,6 +216,13 @@ test_object_cmd() {
|
||||
ipfs object stat /ipfs/$N3/foo/baz > /dev/null
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs object patch add-link' allow linking IPLD objects" '
|
||||
EMPTY_DIR=$(ipfs object new unixfs-dir) &&
|
||||
OBJ=$(echo "123" | ipfs dag put) &&
|
||||
N1=$(ipfs object patch $EMPTY_DIR add-link foo $OBJ) &&
|
||||
ipfs object stat $N1 > /dev/null
|
||||
'
|
||||
|
||||
test_expect_success "object patch creation looks right" '
|
||||
echo "QmPc73aWK9dgFBXe86P4PvQizHo9e5Qt7n7DAMXWuigFuG" > hash_exp &&
|
||||
echo $N3 > hash_actual &&
|
||||
|
||||
Loading…
Reference in New Issue
Block a user