Skip to content

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

:bug: 导入 `.sy.zip` 后查询嵌入块失效 Fix https://github.com/siyuan-note/siyuan/issues/5316

Liang Ding8d933b5669c7
diff --git a/kernel/model/import.go b/kernel/model/import.go
index f5aabfae6b..a103a51440 100644
--- a/kernel/model/import.go
+++ b/kernel/model/import.go
@@ -116,7 +116,7 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
trees[tree.ID] = tree
}
- // 引用指向重新生成的块 ID
+ // 引用和嵌入指向重新生成的块 ID
for _, tree := range trees {
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering {
@@ -129,6 +129,11 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
} else {
util.LogWarnf("not found def [" + n.TokensStr() + "]")
}
+ } else if ast.NodeBlockQueryEmbedScript == n.Type {
+ for oldID, newID := range blockIDs {
+ // 导入 `.sy.zip` 后查询嵌入块失效 https://github.com/siyuan-note/siyuan/issues/5316
+ n.Tokens = bytes.ReplaceAll(n.Tokens, []byte(oldID), []byte(newID))
+ }
}
return ast.WalkContinue
})