mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-15 22:20:13 +01:00
🎨 Improve ocr bin detect https://github.com/siyuan-note/siyuan/issues/7107#issuecomment-3541763667
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
f293fa5d26
commit
8e9cc60909
1 changed files with 10 additions and 6 deletions
|
|
@ -361,17 +361,21 @@ func getTesseractVer() (ret string) {
|
|||
gulu.CmdAttr(cmd)
|
||||
data, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "executable file not found") {
|
||||
errMsg := strings.ToLower(err.Error())
|
||||
if strings.Contains(errMsg, "executable file not found") || strings.Contains(errMsg, "no such file or directory") {
|
||||
// macOS 端 Tesseract OCR 安装后不识别 https://github.com/siyuan-note/siyuan/issues/7107
|
||||
TesseractBin = "/usr/local/bin/tesseract"
|
||||
cmd = exec.Command(TesseractBin, "--version")
|
||||
gulu.CmdAttr(cmd)
|
||||
data, err = cmd.CombinedOutput()
|
||||
if err != nil && strings.Contains(err.Error(), "executable file not found") {
|
||||
TesseractBin = "/opt/homebrew/bin/tesseract"
|
||||
cmd = exec.Command(TesseractBin, "--version")
|
||||
gulu.CmdAttr(cmd)
|
||||
data, err = cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
errMsg = strings.ToLower(err.Error())
|
||||
if strings.Contains(errMsg, "executable file not found") || strings.Contains(errMsg, "no such file or directory") {
|
||||
TesseractBin = "/opt/homebrew/bin/tesseract"
|
||||
cmd = exec.Command(TesseractBin, "--version")
|
||||
gulu.CmdAttr(cmd)
|
||||
data, err = cmd.CombinedOutput()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue