From a5a82795ada1df42ca33018b308df798ca3bf458 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sat, 22 Nov 2025 14:43:03 +0800 Subject: [PATCH] :art: Image OCR supports setting the timeout via the environment variable `SIYUAN_TESSERACT_TIMEOUT` https://github.com/siyuan-note/siyuan/issues/16419 Signed-off-by: Daniel <845765@qq.com> --- kernel/util/ocr.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/util/ocr.go b/kernel/util/ocr.go index c3935212a..b03824756 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 }