mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-02-28 05:32:52 +00:00
🎨 Improve asset rename ocr text https://github.com/siyuan-note/siyuan/issues/12974
This commit is contained in:
@@ -655,6 +655,12 @@ func RenameAsset(oldPath, newName string) (newPath string, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
if ocrText := util.GetAssetText(oldPath); "" != ocrText {
|
||||
// 图片重命名后 ocr-texts.json 需要更新 https://github.com/siyuan-note/siyuan/issues/12974
|
||||
util.SetAssetText(newPath, ocrText)
|
||||
util.RemoveAssetText(oldPath)
|
||||
}
|
||||
|
||||
IncSync()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -164,12 +164,21 @@ func OcrAsset(asset string) (ret []map[string]interface{}) {
|
||||
return
|
||||
}
|
||||
|
||||
// https://github.com/siyuan-note/siyuan/pull/11708
|
||||
func GetAssetText(asset string) (ret string) {
|
||||
assetsTextsLock.Lock()
|
||||
ret = assetsTexts[asset]
|
||||
assetsTextsLock.Unlock()
|
||||
assetsTextsChanged.Store(true)
|
||||
return
|
||||
}
|
||||
|
||||
func RemoveAssetText(asset string) {
|
||||
assetsTextsLock.Lock()
|
||||
delete(assetsTexts, asset)
|
||||
assetsTextsLock.Unlock()
|
||||
assetsTextsChanged.Store(true)
|
||||
}
|
||||
|
||||
func IsTesseractExtractable(p string) bool {
|
||||
lowerName := strings.ToLower(p)
|
||||
return strings.HasSuffix(lowerName, ".png") || strings.HasSuffix(lowerName, ".jpg") || strings.HasSuffix(lowerName, ".jpeg")
|
||||
|
||||
Reference in New Issue
Block a user