🎨 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113

This commit is contained in:
Liang Ding 2023-01-25 20:42:05 +08:00
parent 07ad00ec95
commit a4d779258c
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
3 changed files with 24 additions and 7 deletions

View file

@ -174,6 +174,11 @@ func checkBlockExist(c *gin.Context) {
ret.Data = id ret.Data = id
return return
} }
if errors.Is(err, model.ErrIndexing) {
ret.Code = 3
ret.Data = id
return
}
ret.Data = nil != b ret.Data = nil != b
} }
@ -377,6 +382,11 @@ func getBlockInfo(c *gin.Context) {
ret.Data = id ret.Data = id
return return
} }
if errors.Is(err, model.ErrIndexing) {
ret.Code = 3
ret.Data = id
return
}
if nil == block { if nil == block {
ret.Code = -1 ret.Code = -1
ret.Msg = fmt.Sprintf(model.Conf.Language(15), id) ret.Msg = fmt.Sprintf(model.Conf.Language(15), id)
@ -403,6 +413,11 @@ func getBlockInfo(c *gin.Context) {
ret.Data = id ret.Data = id
return return
} }
if errors.Is(err, model.ErrIndexing) {
ret.Code = 3
ret.Data = id
return
}
rootTitle := root.IAL["title"] rootTitle := root.IAL["title"]
rootTitle = html.UnescapeString(rootTitle) rootTitle = html.UnescapeString(rootTitle)
ret.Data = map[string]string{ ret.Data = map[string]string{

View file

@ -393,11 +393,10 @@ func getBlock(id string) (ret *Block, err error) {
tree, err := loadTreeByBlockID(id) tree, err := loadTreeByBlockID(id)
if nil != err { if nil != err {
waitForIndexing() if indexing {
tree, err = loadTreeByBlockID(id) err = ErrIndexing
if nil != err {
return
} }
return
} }
node := treenode.GetNodeInTree(tree, id) node := treenode.GetNodeInTree(tree, id)

View file

@ -138,9 +138,12 @@ func loadTree(localPath string, luteEngine *lute.Lute) (ret *parse.Tree, err err
return return
} }
var ErrBoxNotFound = errors.New("notebook not found") var (
var ErrBlockNotFound = errors.New("block not found") ErrBoxNotFound = errors.New("notebook not found")
var ErrTreeNotFound = errors.New("tree not found") ErrBlockNotFound = errors.New("block not found")
ErrTreeNotFound = errors.New("tree not found")
ErrIndexing = errors.New("indexing")
)
func loadTreeByBlockID(id string) (ret *parse.Tree, err error) { func loadTreeByBlockID(id string) (ret *parse.Tree, err error) {
if "" == id { if "" == id {