@cryptotaxi247 / kubo / commits / 74c4735b6

object put: allow empty objects

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>

Łukasz Magiera committed May 14, 2019 at 18:26 UTC 74c4735b6643d3df1f85c8c7468bbb3f0b0001bc
1 file changed -16
core/coreapi/object.go
-16
@@ -78,12 +78,6 @@ func (api *ObjectAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.Obj
78 return nil, err
79 }
80
81 - // check that we have data in the Node to add
82 - // otherwise we will add the empty object without raising an error
83 - if nodeEmpty(node) {
84 - return nil, errors.New("no data or links in this node")
85 - }
86 -
81 dagnode, err = deserializeNode(node, options.DataType)
82 if err != nil {
83 return nil, err
@@ -99,12 +93,6 @@ func (api *ObjectAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.Obj
93 return nil, err
94 }
95
102 - // check that we have data in the Node to add
103 - // otherwise we will add the empty object without raising an error
104 - if nodeEmpty(node) {
105 - return nil, errors.New("no data or links in this node")
106 - }
107 -
96 dagnode, err = deserializeNode(node, options.DataType)
97 if err != nil {
98 return nil, err
@@ -368,7 +356,3 @@ func deserializeNode(nd *Node, dataFieldEncoding string) (*dag.ProtoNode, error)
356
357 return dagnode, nil
358 }
371 -
372 -func nodeEmpty(node *Node) bool {
373 - return node.Data == "" && len(node.Links) == 0
374 -}