An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve asset rename ocr text https://github.com/siyuan-note/siyuan/issues/12974
Danielaab613194507
diff --git a/kernel/model/assets.go b/kernel/model/assets.goindex dc6ae71f55..879463a0e6 100644--- a/kernel/model/assets.go+++ b/kernel/model/assets.go@@ -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}diff --git a/kernel/util/ocr.go b/kernel/util/ocr.goindex 83ecd96fc8..cd43271065 100644--- a/kernel/util/ocr.go+++ b/kernel/util/ocr.go@@ -164,12 +164,21 @@ func OcrAsset(asset string) (ret []map[string]interface{}) {return}-// https://github.com/siyuan-note/siyuan/pull/11708func 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")