An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Fix snapshot AV rendering for encrypted notebooks https://github.com/siyuan-note/siyuan/issues/18034
Daniela68d0252889f
diff --git a/kernel/model/attribute_view_render.go b/kernel/model/attribute_view_render.goindex a902aa85e4..69950676f7 100644--- a/kernel/model/attribute_view_render.go+++ b/kernel/model/attribute_view_render.go@@ -539,6 +539,18 @@ func getRenderAttributeViewView(attrView *av.AttributeView, viewID, nodeID strinreturn}+// avBoxIDFromRepoPath 从快照文件路径反查 boxID。+// 全局路径 /storage/av/<avID>.json 返回空串;加密 box 路径 /<boxID>/storage/av/<avID>.json 返回 boxID。+func avBoxIDFromRepoPath(repoPath string) string {+ parts := strings.Split(repoPath, "/")+ // 全局路径: ["", "storage", "av", "xxx.json"] → parts[1]=="storage"+ // 加密 box: ["", "<boxID>", "storage", "av", "xxx.json"] → parts[1]=="<boxID>"+ if len(parts) >= 4 && parts[2] == "storage" {+ return parts[1]+ }+ return ""+}+func RenderRepoSnapshotAttributeView(indexID, avID string) (viewable av.Viewable, attrView *av.AttributeView, err error) {repo, err := newRepository()if err != nil {@@ -556,7 +568,8 @@ func RenderRepoSnapshotAttributeView(indexID, avID string) (viewable av.Viewable}var avFile *entity.Filefor _, f := range files {- if "/storage/av/"+avID+".json" == f.Path {+ // 匹配全局 /storage/av/<avID>.json 或加密 box /<boxID>/storage/av/<avID>.json+ if strings.HasSuffix(f.Path, "/storage/av/"+avID+".json") {avFile = fbreak}@@ -580,6 +593,17 @@ func RenderRepoSnapshotAttributeView(indexID, avID string) (viewable av.Viewablereturn}+ // 加密笔记本的 AV 在快照中是密文,按路径反查 boxID 后解密+ if histBoxID := avBoxIDFromRepoPath(avFile.Path); histBoxID != "" && IsEncryptedBox(histBoxID) {+ dec, decErr := av.DecryptAVData(histBoxID, data)+ if decErr != nil {+ logging.LogErrorf("decrypt snapshot attribute view [%s] failed: %s", avID, decErr)+ err = decErr+ return+ }+ data = dec+ }+if !ast.IsNodeIDPattern(avID) {err = ErrInvalidIDreturn