🎨 Shallow clone the corresponding database when the template contains database blocks https://github.com/siyuan-note/siyuan/issues/9494

This commit is contained in:
Daniel 2023-10-24 09:33:59 +08:00
parent d8bb02fb20
commit 7145460c18
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 57 additions and 0 deletions

View file

@ -20,6 +20,7 @@ import (
"bytes"
"errors"
"fmt"
"github.com/siyuan-note/siyuan/kernel/av"
"io/fs"
"os"
"path/filepath"
@ -277,6 +278,23 @@ func renderTemplate(p, id string) (string, error) {
n.TextMarkInlineMathContent = strings.ReplaceAll(n.TextMarkInlineMathContent, "|", "|")
}
}
if ast.NodeAttributeView == n.Type {
// 重新生成数据库视图
attrView, parseErr := av.ParseAttributeView(n.AttributeViewID)
if nil != parseErr {
logging.LogErrorf("parse attribute view [%s] failed: %s", n.AttributeViewID, parseErr)
} else {
cloned := av.CloneAttributeView(attrView)
if nil != cloned {
n.AttributeViewID = cloned.ID
if saveErr := av.SaveAttributeView(cloned); nil != saveErr {
logging.LogErrorf("save attribute view [%s] failed: %s", cloned.ID, saveErr)
}
}
}
}
return ast.WalkContinue
})
for _, n := range nodesNeedAppendChild {