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
Daniel960cf3fe0450
diff --git a/kernel/api/av.go b/kernel/api/av.goindex f945c9fe5a..bd6d723db1 100644--- a/kernel/api/av.go+++ b/kernel/api/av.go@@ -21,6 +21,7 @@ import ("github.com/88250/gulu""github.com/gin-gonic/gin"+ "github.com/siyuan-note/siyuan/kernel/av""github.com/siyuan-note/siyuan/kernel/model""github.com/siyuan-note/siyuan/kernel/util")@@ -60,6 +61,7 @@ func renderAttributeView(c *gin.Context) {"viewID": view.GetID(),"views": views,"view": view,+ "isMirror": av.IsMirror(attrView.ID),}}diff --git a/kernel/av/av.go b/kernel/av/av.goindex 2a6b38c0d4..6385a4224d 100644--- a/kernel/av/av.go+++ b/kernel/av/av.go@@ -590,6 +590,31 @@ var (attributeViewBlocksLock = sync.Mutex{})+func IsMirror(avID string) bool {+ attributeViewBlocksLock.Lock()+ defer attributeViewBlocksLock.Unlock()++ blocks := filepath.Join(util.DataDir, "storage", "av", "blocks.msgpack")+ if !gulu.File.IsExist(blocks) {+ return false+ }++ data, err := filelock.ReadFile(blocks)+ if nil != err {+ logging.LogErrorf("read attribute view blocks failed: %s", err)+ return false+ }++ avBlocks := map[string][]string{}+ if err = msgpack.Unmarshal(data, &avBlocks); nil != err {+ logging.LogErrorf("unmarshal attribute view blocks failed: %s", err)+ return false+ }++ blockIDs := avBlocks[avID]+ return nil != blockIDs && 1 < len(blockIDs)+}+func RemoveBlockRel(avID, blockID string) {attributeViewBlocksLock.Lock()defer attributeViewBlocksLock.Unlock()