🎨 Improve ocr text indexing

* 调用 setImageOCRText 后重建资源索引

* 优化性能
This commit is contained in:
崮生 2024-09-12 22:59:22 +08:00 committed by GitHub
parent d9fd9f68d2
commit 0309e1772e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -29,6 +29,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/util"
)
@ -128,6 +129,14 @@ func setImageOCRText(c *gin.Context) {
path := arg["path"].(string)
text := arg["text"].(string)
util.SetAssetText(path, text)
// 刷新 OCR 结果到数据库
util.NodeOCRQueueLock.Lock()
defer util.NodeOCRQueueLock.Unlock()
for _, id := range util.NodeOCRQueue {
sql.IndexNodeQueue(id)
}
util.NodeOCRQueue = nil
}
func ocr(c *gin.Context) {