mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-22 12:51:19 +08:00
invalidate merkledag cache when modifying children
This commit is contained in:
@ -87,6 +87,7 @@ func (l *Link) GetNode(serv DAGService) (*Node, error) {
|
|||||||
|
|
||||||
// AddNodeLink adds a link to another node.
|
// AddNodeLink adds a link to another node.
|
||||||
func (n *Node) AddNodeLink(name string, that *Node) error {
|
func (n *Node) AddNodeLink(name string, that *Node) error {
|
||||||
|
n.encoded = nil
|
||||||
lnk, err := MakeLink(that)
|
lnk, err := MakeLink(that)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -101,6 +102,7 @@ func (n *Node) AddNodeLink(name string, that *Node) error {
|
|||||||
// AddNodeLink adds a link to another node. without keeping a reference to
|
// AddNodeLink adds a link to another node. without keeping a reference to
|
||||||
// the child node
|
// the child node
|
||||||
func (n *Node) AddNodeLinkClean(name string, that *Node) error {
|
func (n *Node) AddNodeLinkClean(name string, that *Node) error {
|
||||||
|
n.encoded = nil
|
||||||
lnk, err := MakeLink(that)
|
lnk, err := MakeLink(that)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -113,6 +115,7 @@ func (n *Node) AddNodeLinkClean(name string, that *Node) error {
|
|||||||
|
|
||||||
// Remove a link on this node by the given name
|
// Remove a link on this node by the given name
|
||||||
func (n *Node) RemoveNodeLink(name string) error {
|
func (n *Node) RemoveNodeLink(name string) error {
|
||||||
|
n.encoded = nil
|
||||||
for i, l := range n.Links {
|
for i, l := range n.Links {
|
||||||
if l.Name == name {
|
if l.Name == name {
|
||||||
n.Links = append(n.Links[:i], n.Links[i+1:]...)
|
n.Links = append(n.Links[:i], n.Links[i+1:]...)
|
||||||
|
Reference in New Issue
Block a user