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

Danielfaeaec707d64
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 27f5a768d5..f4e9cc727e 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -209,19 +209,19 @@ func RenderRepoSnapshotAttributeView(indexID, avID string) (viewable av.Viewable
}
if nil == avFile {
- return
- }
-
- data, readErr := repo.OpenFile(avFile)
- if nil != readErr {
- logging.LogErrorf("read attribute view [%s] failed: %s", avID, readErr)
- return
- }
+ attrView = av.NewAttributeView(avID)
+ } else {
+ data, readErr := repo.OpenFile(avFile)
+ if nil != readErr {
+ logging.LogErrorf("read attribute view [%s] failed: %s", avID, readErr)
+ return
+ }
- attrView = &av.AttributeView{}
- if err = gulu.JSON.UnmarshalJSON(data, attrView); nil != err {
- logging.LogErrorf("unmarshal attribute view [%s] failed: %s", avID, err)
- return
+ attrView = &av.AttributeView{}
+ if err = gulu.JSON.UnmarshalJSON(data, attrView); nil != err {
+ logging.LogErrorf("unmarshal attribute view [%s] failed: %s", avID, err)
+ return
+ }
}
viewable, err = renderAttributeView(attrView)
@@ -249,19 +249,22 @@ func RenderHistoryAttributeView(avID, created string) (viewable av.Viewable, att
historyDir := matches[0]
avJSONPath := filepath.Join(historyDir, "storage", "av", avID+".json")
if !gulu.File.IsExist(avJSONPath) {
- return
- }
-
- data, readErr := os.ReadFile(avJSONPath)
- if nil != readErr {
- logging.LogErrorf("read attribute view [%s] failed: %s", avID, readErr)
- return
+ avJSONPath = filepath.Join(util.DataDir, "storage", "av", avID+".json")
}
+ if !gulu.File.IsExist(avJSONPath) {
+ attrView = av.NewAttributeView(avID)
+ } else {
+ data, readErr := os.ReadFile(avJSONPath)
+ if nil != readErr {
+ logging.LogErrorf("read attribute view [%s] failed: %s", avID, readErr)
+ return
+ }
- attrView = &av.AttributeView{}
- if err = gulu.JSON.UnmarshalJSON(data, attrView); nil != err {
- logging.LogErrorf("unmarshal attribute view [%s] failed: %s", avID, err)
- return
+ attrView = &av.AttributeView{}
+ if err = gulu.JSON.UnmarshalJSON(data, attrView); nil != err {
+ logging.LogErrorf("unmarshal attribute view [%s] failed: %s", avID, err)
+ return
+ }
}
viewable, err = renderAttributeView(attrView)