Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2024-09-27 00:21:53 +08:00
commit e675379c08
2 changed files with 12 additions and 3 deletions

View file

@ -118,6 +118,10 @@ func (tx *Transaction) doUnfoldHeading(operation *Operation) (ret *TxErr) {
}
func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath string, err error) {
if !ast.IsNodeIDPattern(srcID) || !ast.IsNodeIDPattern(targetID) {
return
}
srcTree, _ := LoadTreeByBlockID(srcID)
if nil == srcTree {
err = ErrBlockNotFound
@ -136,9 +140,14 @@ func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath st
}
}
if nil == treenode.GetBlockTree(targetID) {
// 目标块不存在时忽略处理
return
}
targetTree, _ := LoadTreeByBlockID(targetID)
if nil == targetTree {
err = ErrBlockNotFound
// 目标块不存在时忽略处理
return
}

View file

@ -203,8 +203,8 @@ func LoadTreeByBlockIDWithReindex(id string) (ret *parse.Tree, err error) {
}
func LoadTreeByBlockID(id string) (ret *parse.Tree, err error) {
if "" == id {
logging.LogErrorf("block id is empty")
if !ast.IsNodeIDPattern(id) {
logging.LogErrorf("block id is invalid [id=%s]", id)
return nil, ErrTreeNotFound
}