mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 06:30:14 +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)
|
gulu.CmdAttr(cmd)
|
||||||
data, err := cmd.CombinedOutput()
|
data, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
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
|
// macOS 端 Tesseract OCR 安装后不识别 https://github.com/siyuan-note/siyuan/issues/7107
|
||||||
TesseractBin = "/usr/local/bin/tesseract"
|
TesseractBin = "/usr/local/bin/tesseract"
|
||||||
cmd = exec.Command(TesseractBin, "--version")
|
cmd = exec.Command(TesseractBin, "--version")
|
||||||
gulu.CmdAttr(cmd)
|
gulu.CmdAttr(cmd)
|
||||||
data, err = cmd.CombinedOutput()
|
data, err = cmd.CombinedOutput()
|
||||||
if err != nil && strings.Contains(err.Error(), "executable file not found") {
|
if err != nil {
|
||||||
TesseractBin = "/opt/homebrew/bin/tesseract"
|
errMsg = strings.ToLower(err.Error())
|
||||||
cmd = exec.Command(TesseractBin, "--version")
|
if strings.Contains(errMsg, "executable file not found") || strings.Contains(errMsg, "no such file or directory") {
|
||||||
gulu.CmdAttr(cmd)
|
TesseractBin = "/opt/homebrew/bin/tesseract"
|
||||||
data, err = cmd.CombinedOutput()
|
cmd = exec.Command(TesseractBin, "--version")
|
||||||
|
gulu.CmdAttr(cmd)
|
||||||
|
data, err = cmd.CombinedOutput()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue