From 524776c0056c7f92967b88da39c8cc826653c84d Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 10 Nov 2023 11:23:27 +0800 Subject: [PATCH] :art: Supports via environment var `SIYUAN_TESSERACT_ENABLED=false` to close OCR Fix https://github.com/siyuan-note/siyuan/issues/9619 --- kernel/model/ocr.go | 5 +++-- kernel/util/tesseract.go | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/model/ocr.go b/kernel/model/ocr.go index 8acb61f8c..067a32232 100644 --- a/kernel/model/ocr.go +++ b/kernel/model/ocr.go @@ -37,8 +37,9 @@ func autoOCRAssets() { util.AssetsTextsLock.Lock() util.AssetsTexts[p] = text util.AssetsTextsLock.Unlock() - util.AssetsTextsChanged = true - + if "" != text { + util.AssetsTextsChanged = true + } if 4 <= i { // 一次任务中最多处理 4 张图片,防止卡顿 break } diff --git a/kernel/util/tesseract.go b/kernel/util/tesseract.go index 17d50ac25..589fd9b3c 100644 --- a/kernel/util/tesseract.go +++ b/kernel/util/tesseract.go @@ -69,7 +69,9 @@ func GetAssetText(asset string, force bool) string { AssetsTextsLock.Lock() AssetsTexts[asset] = ret AssetsTextsLock.Unlock() - AssetsTextsChanged = true + if "" != ret { + AssetsTextsChanged = true + } return ret }