🎨 Maintain relationships between database blocks and database storage Fix https://github.com/siyuan-note/siyuan/issues/9496

This commit is contained in:
Daniel 2023-11-02 10:32:18 +08:00
parent af6036eefe
commit 903b046ce1
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 105 additions and 0 deletions

View file

@ -712,6 +712,10 @@ func (tx *Transaction) doDelete(operation *Operation) (ret *TxErr) {
}
syncDelete2AttributeView(node)
if ast.NodeAttributeView == node.Type {
avID := node.AttributeViewID
av.RemoveBlockRel(avID, node.ID)
}
return
}
@ -898,6 +902,11 @@ func (tx *Transaction) doInsert(operation *Operation) (ret *TxErr) {
return &TxErr{code: TxErrCodeWriteTree, msg: err.Error(), id: block.ID}
}
if ast.NodeAttributeView == insertedNode.Type {
avID := insertedNode.AttributeViewID
av.UpsertBlockRel(avID, insertedNode.ID)
}
operation.ID = insertedNode.ID
operation.ParentID = insertedNode.Parent.ID
return
@ -986,6 +995,11 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
if err = tx.writeTree(tree); nil != err {
return &TxErr{code: TxErrCodeWriteTree, msg: err.Error(), id: id}
}
if ast.NodeAttributeView == updatedNode.Type {
avID := updatedNode.AttributeViewID
av.UpsertBlockRel(avID, updatedNode.ID)
}
return
}