mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
🎨 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:
parent
0d5af87da2
commit
3cbb6138ed
2 changed files with 33 additions and 28 deletions
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -780,41 +780,45 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
attrView, err := av.ParseAttributeView(avID)
|
if isMirror {
|
||||||
if nil != err {
|
// 删除镜像数据库节点后不需要解绑块,因为其他镜像节点还在使用
|
||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
trees, nodes := getAttrViewBoundNodes(attrView)
|
attrView, err := av.ParseAttributeView(avID)
|
||||||
for _, toChangNode := range nodes {
|
if nil != err {
|
||||||
avs := toChangNode.IALAttr(av.NodeAttrNameAvs)
|
return ast.WalkContinue
|
||||||
if "" != avs {
|
}
|
||||||
avIDs := strings.Split(avs, ",")
|
|
||||||
avIDs = gulu.Str.RemoveElem(avIDs, avID)
|
trees, nodes := getAttrViewBoundNodes(attrView)
|
||||||
if 1 > len(avIDs) {
|
for _, toChangNode := range nodes {
|
||||||
toChangNode.RemoveIALAttr(av.NodeAttrNameAvs)
|
avs := toChangNode.IALAttr(av.NodeAttrNameAvs)
|
||||||
} else {
|
if "" != avs {
|
||||||
toChangNode.SetIALAttr(av.NodeAttrNameAvs, strings.Join(avIDs, ","))
|
avIDs := strings.Split(avs, ",")
|
||||||
}
|
avIDs = gulu.Str.RemoveElem(avIDs, avID)
|
||||||
|
if 1 > len(avIDs) {
|
||||||
|
toChangNode.RemoveIALAttr(av.NodeAttrNameAvs)
|
||||||
|
} else {
|
||||||
|
toChangNode.SetIALAttr(av.NodeAttrNameAvs, strings.Join(avIDs, ","))
|
||||||
}
|
}
|
||||||
avNames := getAvNames(toChangNode.IALAttr(av.NodeAttrNameAvs))
|
|
||||||
oldAttrs := parse.IAL2Map(toChangNode.KramdownIAL)
|
|
||||||
toChangNode.SetIALAttr(av.NodeAttrViewNames, avNames)
|
|
||||||
pushBroadcastAttrTransactions(oldAttrs, toChangNode)
|
|
||||||
}
|
|
||||||
for _, tree := range trees {
|
|
||||||
indexWriteTreeUpsertQueue(tree)
|
|
||||||
}
|
}
|
||||||
|
avNames := getAvNames(toChangNode.IALAttr(av.NodeAttrNameAvs))
|
||||||
|
oldAttrs := parse.IAL2Map(toChangNode.KramdownIAL)
|
||||||
|
toChangNode.SetIALAttr(av.NodeAttrViewNames, avNames)
|
||||||
|
pushBroadcastAttrTransactions(oldAttrs, toChangNode)
|
||||||
|
}
|
||||||
|
for _, tree := range trees {
|
||||||
|
indexWriteTreeUpsertQueue(tree)
|
||||||
}
|
}
|
||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue