Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/17957

Danielb639f4e88e93
diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go
index d70b5688b6..bd94f7cfa4 100644
--- a/kernel/model/transaction.go
+++ b/kernel/model/transaction.go
@@ -313,10 +313,10 @@ func performTx(tx *Transaction) (ret *TxErr) {
ret = tx.doSetAttrViewViewIcon(op)
case "setAttrViewViewDesc":
ret = tx.doSetAttrViewViewDesc(op)
- case "duplicateAttrViewView":
- ret = tx.doDuplicateAttrViewView(op)
- case "duplicateAttrViewRow":
- ret = tx.doDuplicateAttrViewRow(op)
+ case "duplicateAttrViewView":
+ ret = tx.doDuplicateAttrViewView(op)
+ case "duplicateAttrViewRow":
+ ret = tx.doDuplicateAttrViewRow(op)
case "sortAttrViewView":
ret = tx.doSortAttrViewView(op)
case "updateAttrViewColRelation":
@@ -987,13 +987,13 @@ func (tx *Transaction) doDelete(operation *Operation) (ret *TxErr) {
return &TxErr{code: TxErrCodeBlockNotFound, id: id}
}
- deletedNode := tx.doDelete0(operation, tree)
- if nil == deletedNode {
- return
- }
- // 同步清理被删除容器块的索引节点及其子节点,否则删除列表/超级块等容器块后其子节点依然存在,ExistBlockTree 仍返回 true
- // Improve editor state synchronization when deleting blocks https://github.com/siyuan-note/siyuan/issues/17742
- deletedIDs := deletedNode.BlockIDs()
+ deletedNode := tx.doDelete0(operation, tree)
+ if nil == deletedNode {
+ return
+ }
+ // 同步清理被删除容器块的索引节点及其子节点,否则删除列表/超级块等容器块后其子节点依然存在,ExistBlockTree 仍返回 true
+ // Improve editor state synchronization when deleting blocks https://github.com/siyuan-note/siyuan/issues/17742
+ deletedIDs := deletedNode.BlockIDs()
treenode.RemoveBlockTreesByIDs(deletedIDs)
tx.writeTree(tree)
return
@@ -1011,6 +1011,8 @@ func (tx *Transaction) doDelete0(operation *Operation, tree *parse.Tree) (delete
for _, defID := range refDefIDs {
task.AppendAsyncTaskWithDelay(task.SetDefRefCount, util.SQLFlushInterval, refreshRefCount, defID)
}
+ // 删除被引用的块后需刷新其所属文档的引用计数,否则源文档级计数角标不会更新
+ task.AppendAsyncTaskWithDelay(task.SetDefRefCount, util.SQLFlushInterval, refreshRefCount, tree.Root.ID)
parent := node.Parent
if nil != node.Next && ast.NodeKramdownBlockIAL == node.Next.Type && bytes.Contains(node.Next.Tokens, []byte(node.ID)) {
@@ -1366,6 +1368,8 @@ func (tx *Transaction) doInsert0(operation *Operation, tree *parse.Tree) (ret *T
for _, defID := range refDefIDs {
task.AppendAsyncTaskWithDelay(task.SetDefRefCount, util.SQLFlushInterval, refreshRefCount, defID)
}
+ // 粘贴被引用的块后需刷新目标文档的引用计数,否则目标文档级计数角标不会更新
+ task.AppendAsyncTaskWithDelay(task.SetDefRefCount, util.SQLFlushInterval, refreshRefCount, tree.Root.ID)
upsertAvBlockRel(insertedNode)