mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
🐛 The save path is incorrect when creating a sub-doc by ref in a doc with the same name Fix https://github.com/siyuan-note/siyuan/issues/8138
This commit is contained in:
parent
c7875757c0
commit
f3dd8e5315
4 changed files with 60 additions and 5 deletions
|
|
@ -130,6 +130,38 @@ func GetBlockTreeRootByHPath(boxID, hPath string) (ret *BlockTree) {
|
|||
return
|
||||
}
|
||||
|
||||
func GetBlockTreeRootByHPathPreferredParentID(boxID, hPath, preferredParentID string) (ret *BlockTree) {
|
||||
var roots []*BlockTree
|
||||
blockTrees.Range(func(key, value interface{}) bool {
|
||||
slice := value.(*btSlice)
|
||||
slice.m.Lock()
|
||||
for _, b := range slice.data {
|
||||
if b.BoxID == boxID && b.HPath == hPath && b.RootID == b.ID {
|
||||
if "" == preferredParentID {
|
||||
ret = b
|
||||
break
|
||||
}
|
||||
|
||||
roots = append(roots, b)
|
||||
}
|
||||
}
|
||||
slice.m.Unlock()
|
||||
return nil == ret
|
||||
})
|
||||
if 1 > len(roots) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, root := range roots {
|
||||
if root.ID == preferredParentID {
|
||||
ret = root
|
||||
return
|
||||
}
|
||||
}
|
||||
ret = roots[0]
|
||||
return
|
||||
}
|
||||
|
||||
func GetBlockTree(id string) (ret *BlockTree) {
|
||||
if "" == id {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue