This commit is contained in:
Liang Ding 2023-01-19 01:15:54 +08:00
parent 2cb6e82330
commit ffed021dda
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
3 changed files with 8 additions and 4 deletions

View File

@ -57,7 +57,7 @@ func autoOCRAssets() {
waitGroup.Add(1) waitGroup.Add(1)
p.Invoke(assetAbsPath) p.Invoke(assetAbsPath)
if 63 <= i { // 一次最多处理 64 张图片,防止卡顿 if 63 <= i { // 一次任务中最多处理 64 张图片,防止卡顿
break break
} }
} }

View File

@ -1225,8 +1225,8 @@ func AutoIndexEmbedBlock() {
} }
func autoIndexEmbedBlock() { func autoIndexEmbedBlock() {
embedBlocks := sql.QueryEmbedBlocks() embedBlocks := sql.QueryEmptyContentEmbedBlocks()
for _, embedBlock := range embedBlocks { for i, embedBlock := range embedBlocks {
stmt := strings.TrimPrefix(embedBlock.Markdown, "{{") stmt := strings.TrimPrefix(embedBlock.Markdown, "{{")
stmt = strings.TrimSuffix(stmt, "}}") stmt = strings.TrimSuffix(stmt, "}}")
blocks := sql.SelectBlocksRawStmtNoParse(stmt, 102400) blocks := sql.SelectBlocksRawStmtNoParse(stmt, 102400)
@ -1234,6 +1234,10 @@ func autoIndexEmbedBlock() {
embedBlock.Content = block.Content embedBlock.Content = block.Content
sql.UpdateBlockContent(embedBlock) sql.UpdateBlockContent(embedBlock)
} }
if 63 <= i { // 一次任务中最多处理 64 个嵌入块,防止卡顿
break
}
} }
} }

View File

@ -31,7 +31,7 @@ import (
"github.com/siyuan-note/siyuan/kernel/util" "github.com/siyuan-note/siyuan/kernel/util"
) )
func QueryEmbedBlocks() (ret []*Block) { func QueryEmptyContentEmbedBlocks() (ret []*Block) {
stmt := "SELECT * FROM blocks WHERE type = 'query_embed' AND content = ''" stmt := "SELECT * FROM blocks WHERE type = 'query_embed' AND content = ''"
rows, err := query(stmt) rows, err := query(stmt)
if nil != err { if nil != err {