🎨 Tesseract OCR 加锁串行执行提升稳定性 Fix https://github.com/siyuan-note/siyuan/issues/7265

This commit is contained in:
Liang Ding 2023-02-06 17:39:49 +08:00
parent a3444452aa
commit 9404330f23
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 8 additions and 22 deletions

View file

@ -64,12 +64,17 @@ func IsTesseractExtractable(p string) bool {
return strings.HasSuffix(lowerName, ".png") || strings.HasSuffix(lowerName, ".jpg") || strings.HasSuffix(lowerName, ".jpeg")
}
// tesseractOCRLock 用于 Tesseract OCR 加锁串行执行提升稳定性 https://github.com/siyuan-note/siyuan/issues/7265
var tesseractOCRLock = sync.Mutex{}
func Tesseract(imgAbsPath string) string {
if ContainerStd != Container || !TesseractEnabled {
return ""
}
defer logging.Recover()
tesseractOCRLock.Lock()
defer tesseractOCRLock.Unlock()
if !IsTesseractExtractable(imgAbsPath) {
return ""