From 0309e1772e1f6dbfc2e31fad02e1bee459b4fa23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=AE=E7=94=9F?= Date: Thu, 12 Sep 2024 22:59:22 +0800 Subject: [PATCH] :art: Improve ocr text indexing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 调用 setImageOCRText 后重建资源索引 * 优化性能 --- kernel/api/asset.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/api/asset.go b/kernel/api/asset.go index 4dbac0c02..c42e438d2 100644 --- a/kernel/api/asset.go +++ b/kernel/api/asset.go @@ -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) {