mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-04-23 19:41:15 -05:00
🎨 Improve getBlockInfo for reindexing https://github.com/siyuan-note/siyuan/issues/10772
This commit is contained in:
+2
-1
@@ -465,7 +465,8 @@ func getBlockInfo(c *gin.Context) {
|
||||
|
||||
id := arg["id"].(string)
|
||||
|
||||
tree, err := model.LoadTreeByBlockID(id)
|
||||
// 仅在此处使用带重建索引的加载函数,其他地方不要使用
|
||||
tree, err := model.LoadTreeByBlockIDWithReindex(id)
|
||||
if errors.Is(err, model.ErrIndexing) {
|
||||
ret.Code = 3
|
||||
ret.Msg = model.Conf.Language(56)
|
||||
|
||||
+22
-1
@@ -153,7 +153,9 @@ var (
|
||||
ErrIndexing = errors.New("indexing")
|
||||
)
|
||||
|
||||
func LoadTreeByBlockID(id string) (ret *parse.Tree, err error) {
|
||||
func LoadTreeByBlockIDWithReindex(id string) (ret *parse.Tree, err error) {
|
||||
// 仅提供给 getBlockInfo 接口使用
|
||||
|
||||
if "" == id {
|
||||
return nil, ErrTreeNotFound
|
||||
}
|
||||
@@ -178,6 +180,25 @@ func LoadTreeByBlockID(id string) (ret *parse.Tree, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func LoadTreeByBlockID(id string) (ret *parse.Tree, err error) {
|
||||
if "" == id {
|
||||
return nil, ErrTreeNotFound
|
||||
}
|
||||
|
||||
bt := treenode.GetBlockTree(id)
|
||||
if nil == bt {
|
||||
if task.Contain(task.DatabaseIndex, task.DatabaseIndexFull) {
|
||||
err = ErrIndexing
|
||||
return
|
||||
}
|
||||
return nil, ErrTreeNotFound
|
||||
}
|
||||
|
||||
luteEngine := util.NewLute()
|
||||
ret, err = filesys.LoadTree(bt.BoxID, bt.Path, luteEngine)
|
||||
return
|
||||
}
|
||||
|
||||
var searchTreeLimiter = rate.NewLimiter(rate.Every(3*time.Second), 1)
|
||||
|
||||
func searchTreeInFilesystem(rootID string) {
|
||||
|
||||
Reference in New Issue
Block a user