Skip to content

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

:art: Support doc/snapshot history for database table view https://github.com/siyuan-note/siyuan/issues/9567

Daniel66211b2f3ff6
diff --git a/kernel/model/history.go b/kernel/model/history.go
index 281a0b8784..3574d499bd 100644
--- a/kernel/model/history.go
+++ b/kernel/model/history.go
@@ -242,6 +242,25 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
return
}
+ tree, _ := loadTree(srcPath, util.NewLute())
+ if nil != tree {
+ historyDir := strings.TrimPrefix(historyPath, util.HistoryDir+string(os.PathSeparator))
+ if strings.Contains(historyDir, string(os.PathSeparator)) {
+ historyDir = historyDir[:strings.Index(historyDir, string(os.PathSeparator))]
+ }
+ historyDir = filepath.Join(util.HistoryDir, historyDir)
+
+ // 恢复包含的的属性视图 https://github.com/siyuan-note/siyuan/issues/9567
+ avNodes := tree.Root.ChildrenByType(ast.NodeAttributeView)
+ for _, avNode := range avNodes {
+ srcAvPath := filepath.Join(historyDir, "storage", "av", avNode.AttributeViewID+".json")
+ destAvPath := filepath.Join(util.DataDir, "storage", "av", avNode.AttributeViewID+".json")
+ if copyErr := filelock.CopyNewtimes(srcAvPath, destAvPath); nil != copyErr {
+ logging.LogErrorf("copy av [%s] failed: %s", srcAvPath, copyErr)
+ }
+ }
+ }
+
util.ReloadUI()
FullReindex()
IncSync()