From 66211b2f3ff6d3b9e4b2e6f0eb9b12aaf9c9e6a1 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 23 Nov 2023 22:58:20 +0800 Subject: [PATCH] :art: Support doc/snapshot history for database table view https://github.com/siyuan-note/siyuan/issues/9567 --- kernel/model/history.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/kernel/model/history.go b/kernel/model/history.go index 281a0b878..3574d499b 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()