An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve synchronization of database bound blocks when list blocks change https://github.com/siyuan-note/siyuan/issues/15697
Daniela154ead980a7
diff --git a/kernel/model/transaction.go b/kernel/model/transaction.goindex 18ab0d7da2..7851dd1915 100644--- a/kernel/model/transaction.go+++ b/kernel/model/transaction.go@@ -961,10 +961,8 @@ func (tx *Transaction) syncDelete2Block(node *ast.Node, nodeTree *parse.Tree) (cpushBroadcastAttrTransactions(oldAttrs, toChangNode)}- nodeTreeID := nodeTree.IDfor _, tree := range trees {- self := nodeTreeID == tree.ID- if !self {+ if nodeTree.ID != tree.ID {indexWriteTreeUpsertQueue(tree)}}@@ -1461,6 +1459,11 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {updatedNode.Tokens = []byte(strings.Join(newLines, "\n"))}+ removedNodes := getRemovedNodes(oldNode, updatedNode)+ for _, n := range removedNodes {+ syncDelete2AvBlock(n, tree, tx)+ }+// 替换为新节点oldNode.InsertAfter(updatedNode)oldNode.Unlink()@@ -1520,6 +1523,30 @@ func getRefDefIDs(node *ast.Node) (refDefIDs []string) {return}+func getRemovedNodes(oldNode, newNode *ast.Node) (ret []*ast.Node) {+ oldNodes := map[string]*ast.Node{}+ ast.Walk(oldNode, func(n *ast.Node, entering bool) ast.WalkStatus {+ if !entering || !n.IsBlock() {+ return ast.WalkContinue+ }+ oldNodes[n.ID] = n+ return ast.WalkContinue+ })+ ast.Walk(newNode, func(n *ast.Node, entering bool) ast.WalkStatus {+ if !entering || !n.IsBlock() {+ return ast.WalkContinue+ }+ if _, ok := oldNodes[n.ID]; ok {+ delete(oldNodes, n.ID)+ }+ return ast.WalkContinue+ })+ for _, n := range oldNodes {+ ret = append(ret, n)+ }+ return+}+func upsertAvBlockRel(node *ast.Node) {var affectedAvIDs []stringast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {