mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
object put: allow empty objects
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
parent
7e9eb72bfc
commit
74c4735b66
@ -78,12 +78,6 @@ func (api *ObjectAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.Obj
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// check that we have data in the Node to add
|
||||
// otherwise we will add the empty object without raising an error
|
||||
if nodeEmpty(node) {
|
||||
return nil, errors.New("no data or links in this node")
|
||||
}
|
||||
|
||||
dagnode, err = deserializeNode(node, options.DataType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -99,12 +93,6 @@ func (api *ObjectAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.Obj
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// check that we have data in the Node to add
|
||||
// otherwise we will add the empty object without raising an error
|
||||
if nodeEmpty(node) {
|
||||
return nil, errors.New("no data or links in this node")
|
||||
}
|
||||
|
||||
dagnode, err = deserializeNode(node, options.DataType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -368,7 +356,3 @@ func deserializeNode(nd *Node, dataFieldEncoding string) (*dag.ProtoNode, error)
|
||||
|
||||
return dagnode, nil
|
||||
}
|
||||
|
||||
func nodeEmpty(node *Node) bool {
|
||||
return node.Data == "" && len(node.Links) == 0
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user