Skip to content

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

:art: Generate file history before converting doc to heading/moving blocks https://github.com/siyuan-note/siyuan/issues/14359

Daniel79bf9a7b6198
diff --git a/kernel/model/history.go b/kernel/model/history.go
index 9cc2b69622..fc700bbf36 100644
--- a/kernel/model/history.go
+++ b/kernel/model/history.go
@@ -239,7 +239,7 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
var destPath, parentHPath string
rootID := util.GetTreeID(historyPath)
workingDoc := treenode.GetBlockTree(rootID)
- if nil != workingDoc {
+ if nil != workingDoc && "d" == workingDoc.Type {
if err = filelock.Remove(filepath.Join(util.DataDir, boxID, workingDoc.Path)); err != nil {
return
}
@@ -304,7 +304,12 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
}
}
for _, nodeID := range duplicatedIDs {
- treenode.ResetNodeID(nodes[nodeID])
+ node := nodes[nodeID]
+ treenode.ResetNodeID(node)
+ if ast.NodeDocument == node.Type {
+ tree.ID = node.ID
+ tree.Path = tree.Path[:strings.LastIndex(tree.Path, "/")] + "/" + node.ID + ".sy"
+ }
}
// 仅重新索引该文档,不进行全量索引