Skip to content

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

:art: Improve database handling when importing .sy.zip https://github.com/siyuan-note/siyuan/issues/11628

Danielcf5ff5283a9e
diff --git a/kernel/model/import.go b/kernel/model/import.go
index 583f06c496..6d09ed4ad6 100644
--- a/kernel/model/import.go
+++ b/kernel/model/import.go
@@ -312,6 +312,25 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
attrViewIDs = append(attrViewIDs, avID)
}
updateBoundBlockAvsAttribute(attrViewIDs)
+
+ // 插入关联关系 https://github.com/siyuan-note/siyuan/issues/11628
+ relationAvs := map[string]string{}
+ for _, avID := range avIDs {
+ attrView, _ := av.ParseAttributeView(avID)
+ if nil == attrView {
+ continue
+ }
+
+ for _, keyValues := range attrView.KeyValues {
+ if nil != keyValues.Key && av.KeyTypeRelation == keyValues.Key.Type && nil != keyValues.Key.Relation {
+ relationAvs[avID] = keyValues.Key.Relation.AvID
+ }
+ }
+ }
+
+ for srcAvID, destAvID := range relationAvs {
+ av.UpsertAvBackRel(srcAvID, destAvID)
+ }
}
// 将关联的闪卡数据合并到默认卡包 data/storage/riff/20230218211946-2kw8jgx 中