Browse Source

:art: Supports via environment var `SIYUAN_TESSERACT_ENABLED=false` to close OCR Fix https://github.com/siyuan-note/siyuan/issues/9619

Daniel 1 year ago
parent
commit
524776c005
2 changed files with 6 additions and 3 deletions
  1. 3 2
      kernel/model/ocr.go
  2. 3 1
      kernel/util/tesseract.go

+ 3 - 2
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
 			}

+ 3 - 1
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
 }