An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Identify the database view whether is a "mirror" https://github.com/siyuan-note/siyuan/issues/9578
Daniele964eddbebfb
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex e72b886a68..ae435fb64f 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -142,6 +142,33 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {}blockIDs := av.GetMirrorBlockIDs(avID)+ if 1 > len(blockIDs) {+ // 老数据兼容处理+ avBts := treenode.GetBlockTreesByType("av")+ for _, avBt := range avBts {+ if nil == avBt {+ continue+ }+ tree, _ := loadTreeByBlockID(avBt.ID)+ if nil == tree {+ continue+ }+ node := treenode.GetNodeInTree(tree, avBt.ID)+ if nil == node {+ continue+ }+ if avID == node.AttributeViewID {+ blockIDs = append(blockIDs, avBt.ID)+ }+ }+ if 1 > len(blockIDs) {+ continue+ }+ blockIDs = gulu.Str.RemoveDuplicatedElem(blockIDs)+ for _, blockID := range blockIDs {+ av.UpsertBlockRel(avID, blockID)+ }+ }ret = append(ret, &BlockAttributeViewKeys{AvID: avID,diff --git a/kernel/treenode/blocktree.go b/kernel/treenode/blocktree.goindex 12787a5818..b8dcf13e05 100644--- a/kernel/treenode/blocktree.go+++ b/kernel/treenode/blocktree.go@@ -53,6 +53,21 @@ type BlockTree struct {Type string // 类型}+func GetBlockTreesByType(typ string) (ret []*BlockTree) {+ blockTrees.Range(func(key, value interface{}) bool {+ slice := value.(*btSlice)+ slice.m.Lock()+ for _, b := range slice.data {+ if b.Type == typ {+ ret = append(ret, b)+ }+ }+ slice.m.Unlock()+ return true+ })+ return+}+func GetBlockTreeByPath(path string) (ret *BlockTree) {blockTrees.Range(func(key, value interface{}) bool {slice := value.(*btSlice)