Browse Source

:art: Clean code

Daniel 7 months ago
parent
commit
c7746d1399
2 changed files with 6 additions and 1 deletions
  1. 4 1
      kernel/api/block.go
  2. 2 0
      kernel/model/blockinfo.go

+ 4 - 1
kernel/api/block.go

@@ -376,7 +376,10 @@ func getRefText(c *gin.Context) {
 	}
 	}
 
 
 	id := arg["id"].(string)
 	id := arg["id"].(string)
-	model.FlushTxQueue()
+	if util.InvalidIDPattern(id, ret) {
+		return
+	}
+
 	refText := model.GetBlockRefText(id)
 	refText := model.GetBlockRefText(id)
 	if "" == refText {
 	if "" == refText {
 		// 空块返回 id https://github.com/siyuan-note/siyuan/issues/10259
 		// 空块返回 id https://github.com/siyuan-note/siyuan/issues/10259

+ 2 - 0
kernel/model/blockinfo.go

@@ -204,6 +204,8 @@ func GetDocsInfo(blockIDs []string, queryRefCount bool, queryAv bool) (rets []*B
 }
 }
 
 
 func GetBlockRefText(id string) string {
 func GetBlockRefText(id string) string {
+	FlushTxQueue()
+
 	bt := treenode.GetBlockTree(id)
 	bt := treenode.GetBlockTree(id)
 	if nil == bt {
 	if nil == bt {
 		return ErrBlockNotFound.Error()
 		return ErrBlockNotFound.Error()