Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 潜在的并发冲突

Liang Dingaddadedcb8fe
diff --git a/kernel/model/ocr.go b/kernel/model/ocr.go
index f6944965e7..89beec505a 100644
--- a/kernel/model/ocr.go
+++ b/kernel/model/ocr.go
@@ -49,11 +49,12 @@ func autoOCRAssets() {
}
func cleanNotExistAssetsTexts() {
- tmp := util.AssetsTexts
+ util.AssetsTextsLock.Lock()
+ defer util.AssetsTextsLock.Unlock()
assetsPath := util.GetDataAssetsAbsPath()
var toRemoves []string
- for asset, _ := range tmp {
+ for asset, _ := range util.AssetsTexts {
assetAbsPath := strings.TrimPrefix(asset, "assets")
assetAbsPath = filepath.Join(assetsPath, assetAbsPath)
if !gulu.File.IsExist(assetAbsPath) {
@@ -61,12 +62,10 @@ func cleanNotExistAssetsTexts() {
}
}
- util.AssetsTextsLock.Lock()
for _, asset := range toRemoves {
delete(util.AssetsTexts, asset)
util.AssetsTextsChanged = true
}
- util.AssetsTextsLock.Unlock()
return
}