🎨 The database-bound block is automatically added to the database after being copied as a replica https://github.com/siyuan-note/siyuan/issues/12140

This commit is contained in:
Daniel 2024-08-04 11:24:04 +08:00
parent 0d5af87da2
commit 3cbb6138ed
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 33 additions and 28 deletions

View file

@ -1653,6 +1653,7 @@ func removeDoc(box *Box, p string, luteEngine *lute.Lute) {
allRemoveRootIDs := []string{tree.ID} allRemoveRootIDs := []string{tree.ID}
allRemoveRootIDs = append(allRemoveRootIDs, removeIDs...) allRemoveRootIDs = append(allRemoveRootIDs, removeIDs...)
allRemoveRootIDs = gulu.Str.RemoveDuplicatedElem(allRemoveRootIDs)
for _, rootID := range allRemoveRootIDs { for _, rootID := range allRemoveRootIDs {
removeTree, _ := LoadTreeByBlockID(rootID) removeTree, _ := LoadTreeByBlockID(rootID)
if nil == removeTree { if nil == removeTree {

View file

@ -780,16 +780,21 @@ func (tx *Transaction) doDelete(operation *Operation) (ret *TxErr) {
func syncDelete2Block(node *ast.Node) { func syncDelete2Block(node *ast.Node) {
var changedAvIDs []string var changedAvIDs []string
ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus { ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering { if !entering || ast.NodeAttributeView != n.Type {
return ast.WalkContinue return ast.WalkContinue
} }
if ast.NodeAttributeView == n.Type {
avID := n.AttributeViewID avID := n.AttributeViewID
isMirror := av.IsMirror(avID)
if changed := av.RemoveBlockRel(avID, n.ID, treenode.ExistBlockTree); changed { if changed := av.RemoveBlockRel(avID, n.ID, treenode.ExistBlockTree); changed {
changedAvIDs = append(changedAvIDs, avID) changedAvIDs = append(changedAvIDs, avID)
} }
if isMirror {
// 删除镜像数据库节点后不需要解绑块,因为其他镜像节点还在使用
return ast.WalkContinue
}
attrView, err := av.ParseAttributeView(avID) attrView, err := av.ParseAttributeView(avID)
if nil != err { if nil != err {
return ast.WalkContinue return ast.WalkContinue
@ -815,7 +820,6 @@ func syncDelete2Block(node *ast.Node) {
for _, tree := range trees { for _, tree := range trees {
indexWriteTreeUpsertQueue(tree) indexWriteTreeUpsertQueue(tree)
} }
}
return ast.WalkContinue return ast.WalkContinue
}) })
changedAvIDs = gulu.Str.RemoveDuplicatedElem(changedAvIDs) changedAvIDs = gulu.Str.RemoveDuplicatedElem(changedAvIDs)