🎨 OCR no longer blocks document loading https://github.com/siyuan-note/siyuan/issues/9230

This commit is contained in:
Daniel 2023-12-07 20:40:16 +08:00
parent b31765d0ab
commit 283917a9a8
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
8 changed files with 123 additions and 11 deletions

View file

@ -52,27 +52,32 @@ func SetAssetText(asset, text string) {
AssetsTextsChanged = true
}
func GetAssetText(asset string, force bool) string {
func ExistsAssetText(asset string) (ret bool) {
AssetsTextsLock.Lock()
_, ret = AssetsTexts[asset]
AssetsTextsLock.Unlock()
return
}
func GetAssetText(asset string, force bool) (ret string) {
if !force {
AssetsTextsLock.Lock()
ret, ok := AssetsTexts[asset]
ret = AssetsTexts[asset]
AssetsTextsLock.Unlock()
if ok {
return ret
}
return
}
assetsPath := GetDataAssetsAbsPath()
assetAbsPath := strings.TrimPrefix(asset, "assets")
assetAbsPath = filepath.Join(assetsPath, assetAbsPath)
ret := Tesseract(assetAbsPath)
ret = Tesseract(assetAbsPath)
AssetsTextsLock.Lock()
AssetsTexts[asset] = ret
AssetsTextsLock.Unlock()
if "" != ret {
AssetsTextsChanged = true
}
return ret
return
}
func IsTesseractExtractable(p string) bool {