mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🎨 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>
This commit is contained in:
parent
bebf8c8e9b
commit
a5a82795ad
1 changed files with 3 additions and 2 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue