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

This commit is contained in:
Daniel 2023-11-23 22:58:20 +08:00
parent 235e54fbf1
commit 66211b2f3f
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -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()