Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Fix AV history generation for encrypted notebooks using FindAttributeViewPath https://github.com/siyuan-note/siyuan/issues/18034

Daniel3e489a45e20a
diff --git a/kernel/model/history.go b/kernel/model/history.go
index 362b70d72c..e1165ecdc9 100644
--- a/kernel/model/history.go
+++ b/kernel/model/history.go
@@ -961,10 +961,11 @@ func generateTreeHistory(tree *parse.Tree, historyDir string) {
func generateAvHistoryInTree(tree *parse.Tree, historyDir string) {
avNodes := tree.Root.ChildrenByType(ast.NodeAttributeView)
for _, avNode := range avNodes {
- // 加密笔记本的 AV 定义在笔记本级目录
- srcAvPath := filepath.Join(util.DataDir, "storage", "av", avNode.AttributeViewID+".json")
- if IsEncryptedBox(tree.Box) {
- srcAvPath = filepath.Join(util.DataDir, tree.Box, "storage", "av", avNode.AttributeViewID+".json")
+ // 用 FindAttributeViewPath 解析 AV 定义的真实路径(自动路由全局/加密 box 笔记本级)
+ srcAvPath, _ := av.FindAttributeViewPath(avNode.AttributeViewID)
+ if srcAvPath == "" {
+ // AV 定义不存在(可能尚未落盘或已删除),跳过
+ continue
}
destAvPath := filepath.Join(historyDir, "storage", "av", avNode.AttributeViewID+".json")
if copyErr := filelock.Copy(srcAvPath, destAvPath); nil != copyErr {