Skip to content

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

:art: Improve db create rows in batch https://github.com/siyuan-note/siyuan/issues/11348

Daniel1ddf8bc44740
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 94a803f763..9e550e248f 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -2220,6 +2220,7 @@ func (tx *Transaction) doInsertAttrViewBlock(operation *Operation) (ret *TxErr)
func AddAttributeViewBlock(tx *Transaction, srcs []map[string]interface{}, avID, blockID, previousBlockID string, ignoreFillFilter bool) (err error) {
slices.Reverse(srcs) // https://github.com/siyuan-note/siyuan/issues/11286
+ now := time.Now().UnixMilli()
for _, src := range srcs {
srcID := src["id"].(string)
isDetached := src["isDetached"].(bool)
@@ -2241,14 +2242,14 @@ func AddAttributeViewBlock(tx *Transaction, srcs []map[string]interface{}, avID,
if nil != src["content"] {
srcContent = src["content"].(string)
}
- if avErr := addAttributeViewBlock(avID, blockID, previousBlockID, srcID, srcContent, isDetached, ignoreFillFilter, tree, tx); nil != avErr {
+ if avErr := addAttributeViewBlock(now, avID, blockID, previousBlockID, srcID, srcContent, isDetached, ignoreFillFilter, tree, tx); nil != avErr {
return avErr
}
}
return
}
-func addAttributeViewBlock(avID, blockID, previousBlockID, addingBlockID, addingBlockContent string, isDetached, ignoreFillFilter bool, tree *parse.Tree, tx *Transaction) (err error) {
+func addAttributeViewBlock(now int64, avID, blockID, previousBlockID, addingBlockID, addingBlockContent string, isDetached, ignoreFillFilter bool, tree *parse.Tree, tx *Transaction) (err error) {
var node *ast.Node
if !isDetached {
node = treenode.GetNodeInTree(tree, addingBlockID)
@@ -2272,8 +2273,6 @@ func addAttributeViewBlock(avID, blockID, previousBlockID, addingBlockID, adding
addingBlockContent = getNodeRefText(node)
}
- now := time.Now().UnixMilli()
-
// 检查是否重复添加相同的块
blockValues := attrView.GetBlockKeyValues()
for _, blockValue := range blockValues.Values {