An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:arrow_up: 数据仓库迁出时忽略 `.tmp` 临时文件 https://github.com/siyuan-note/siyuan/issues/7087
Liang Ding15cd499f564f
diff --git a/kernel/util/ocr.go b/kernel/util/ocr.goindex 9c6b305c52..9eef498d53 100644--- a/kernel/util/ocr.go+++ b/kernel/util/ocr.go@@ -105,34 +105,63 @@ func AutoOCRAssets() {}for {- assetsPath := GetDataAssetsAbsPath()- assets := getUnOCRAssetsAbsPaths()-- waitGroup := &sync.WaitGroup{}- lock := &sync.Mutex{}- p, _ := ants.NewPoolWithFunc(4, func(arg interface{}) {- defer waitGroup.Done()-- assetAbsPath := arg.(string)- text := Tesseract(assetAbsPath)- p := strings.TrimPrefix(assetAbsPath, assetsPath)- p = "assets" + filepath.ToSlash(p)- lock.Lock()- assetsTexts[p] = text- lock.Unlock()- assetsTextsChanged = true- })- for _, assetAbsPath := range assets {- waitGroup.Add(1)- p.Invoke(assetAbsPath)- }- waitGroup.Wait()- p.Release()+ autoOCRAssets()time.Sleep(7 * time.Second)}}+func autoOCRAssets() {+ defer logging.Recover()++ assetsPath := GetDataAssetsAbsPath()+ assets := getUnOCRAssetsAbsPaths()++ waitGroup := &sync.WaitGroup{}+ p, _ := ants.NewPoolWithFunc(4, func(arg interface{}) {+ defer waitGroup.Done()++ assetAbsPath := arg.(string)+ text := Tesseract(assetAbsPath)+ p := strings.TrimPrefix(assetAbsPath, assetsPath)+ p = "assets" + filepath.ToSlash(p)+ assetsTextsLock.Lock()+ assetsTexts[p] = text+ assetsTextsLock.Unlock()+ assetsTextsChanged = true+ })+ for _, assetAbsPath := range assets {+ waitGroup.Add(1)+ p.Invoke(assetAbsPath)+ }+ waitGroup.Wait()+ p.Release()++ cleanNotFoundAssetsTexts()+}++func cleanNotFoundAssetsTexts() {+ tmp := assetsTexts++ assetsPath := GetDataAssetsAbsPath()+ var toRemoves []string+ for asset, _ := range tmp {+ assetAbsPath := strings.TrimPrefix(asset, "assets")+ assetAbsPath = filepath.Join(assetsPath, assetAbsPath)+ if !gulu.File.IsExist(assetAbsPath) {+ toRemoves = append(toRemoves, asset)+ }+ }++ assetsTextsLock.Lock()+ for _, asset := range toRemoves {+ delete(assetsTexts, asset)+ assetsTextsChanged = true+ }+ assetsTextsLock.Unlock()+ return+}+func getUnOCRAssetsAbsPaths() (ret []string) {assetsPath := GetDataAssetsAbsPath()var assetsPaths []string