mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-17 01:21:14 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
8aead228d4
@ -33,7 +33,6 @@ import (
|
|||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
"github.com/siyuan-note/riff"
|
"github.com/siyuan-note/riff"
|
||||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
|
||||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
@ -367,32 +366,9 @@ func getTreeSubTreeChildBlocks(rootID string) (treeBlockIDs []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
trees := []*parse.Tree{tree}
|
bts := treenode.GetBlockTreesByPathPrefix(strings.TrimSuffix(tree.Path, ".sy"))
|
||||||
box := Conf.Box(tree.Box)
|
for _, bt := range bts {
|
||||||
luteEngine := util.NewLute()
|
treeBlockIDs = append(treeBlockIDs, bt.ID)
|
||||||
files := box.ListFiles(tree.Path)
|
|
||||||
for _, subFile := range files {
|
|
||||||
if !strings.HasSuffix(subFile.path, ".sy") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
subTree, loadErr := filesys.LoadTree(box.ID, subFile.path, luteEngine)
|
|
||||||
if nil != loadErr {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
trees = append(trees, subTree)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, t := range trees {
|
|
||||||
ast.Walk(t.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
|
||||||
if !entering || !n.IsBlock() {
|
|
||||||
return ast.WalkContinue
|
|
||||||
}
|
|
||||||
|
|
||||||
treeBlockIDs = append(treeBlockIDs, n.ID)
|
|
||||||
return ast.WalkContinue
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -180,6 +180,21 @@ func RemoveBlockTreesByRootID(rootID string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetBlockTreesByPathPrefix(pathPrefix string) (ret []*BlockTree) {
|
||||||
|
blockTrees.Range(func(key, value interface{}) bool {
|
||||||
|
slice := value.(*btSlice)
|
||||||
|
slice.m.Lock()
|
||||||
|
for _, b := range slice.data {
|
||||||
|
if strings.HasPrefix(b.Path, pathPrefix) {
|
||||||
|
ret = append(ret, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
slice.m.Unlock()
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func RemoveBlockTreesByPathPrefix(pathPrefix string) {
|
func RemoveBlockTreesByPathPrefix(pathPrefix string) {
|
||||||
var ids []string
|
var ids []string
|
||||||
blockTrees.Range(func(key, value interface{}) bool {
|
blockTrees.Range(func(key, value interface{}) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user