Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Image OCR supports setting the timeout via the environment variable `SIYUAN_TESSERACT_TIMEOUT` https://github.com/siyuan-note/siyuan/issues/16419

Daniela5a82795ada1
diff --git a/kernel/util/ocr.go b/kernel/util/ocr.go
index c3935212a2..b038247564 100644
--- a/kernel/util/ocr.go
+++ b/kernel/util/ocr.go
@@ -19,6 +19,7 @@ package util
import (
"bytes"
"context"
+ "errors"
"fmt"
"os"
"os/exec"
@@ -249,8 +250,8 @@ func Tesseract(imgAbsPath string) (ret []map[string]interface{}) {
cmd := exec.CommandContext(ctx, TesseractBin, "-c", "debug_file=/dev/null", imgAbsPath, "stdout", "-l", strings.Join(TesseractLangs, "+"), "tsv")
gulu.CmdAttr(cmd)
output, err := cmd.CombinedOutput()
- if ctx.Err() == context.DeadlineExceeded {
- logging.LogWarnf("tesseract [path=%s, size=%d] timeout", imgAbsPath, info.Size())
+ if errors.Is(ctx.Err(), context.DeadlineExceeded) {
+ logging.LogWarnf("tesseract [path=%s, size=%d] timeout [%dms]", imgAbsPath, info.Size(), timeout)
return
}