Skip to content

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

:bug: Blocks created via template update time earlier than creation time Fix https://github.com/siyuan-note/siyuan/issues/8607

Daniel32dee71bb90a
diff --git a/kernel/model/template.go b/kernel/model/template.go
index a4e295fd86..419c262838 100644
--- a/kernel/model/template.go
+++ b/kernel/model/template.go
@@ -250,6 +250,9 @@ func renderTemplate(p, id string) (string, error) {
// 重新生成 ID
n.ID = ast.NewNodeID()
n.SetIALAttr("id", n.ID)
+
+ // Blocks created via template update time earlier than creation time https://github.com/siyuan-note/siyuan/issues/8607
+ refreshUpdated(n)
}
if (ast.NodeListItem == n.Type && (nil == n.FirstChild ||
diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go
index 2b0192af3b..857619ba09 100644
--- a/kernel/model/transaction.go
+++ b/kernel/model/transaction.go
@@ -989,10 +989,10 @@ func (tx *Transaction) doSetAttrs(operation *Operation) (ret *TxErr) {
return
}
-func refreshUpdated(n *ast.Node) {
+func refreshUpdated(node *ast.Node) {
updated := util.CurrentTimeSecondsStr()
- n.SetIALAttr("updated", updated)
- parents := treenode.ParentNodes(n)
+ node.SetIALAttr("updated", updated)
+ parents := treenode.ParentNodes(node)
for _, parent := range parents { // 更新所有父节点的更新时间字段
parent.SetIALAttr("updated", updated)
}