mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-04 17:02:12 +08:00
🎨 OCR no longer blocks document loading https://github.com/siyuan-note/siyuan/issues/9230
This commit is contained in:
parent
1dc5a371f6
commit
aaf15c77e0
@ -586,15 +586,13 @@ func NewLute() (ret *lute.Lute) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var confSaveLock = sync.Mutex{}
|
|
||||||
|
|
||||||
func (conf *AppConf) Save() {
|
func (conf *AppConf) Save() {
|
||||||
if util.ReadOnly {
|
if util.ReadOnly {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
confSaveLock.Lock()
|
Conf.m.Lock()
|
||||||
defer confSaveLock.Unlock()
|
defer Conf.m.Unlock()
|
||||||
|
|
||||||
newData, _ := gulu.JSON.MarshalIndentJSON(Conf, "", " ")
|
newData, _ := gulu.JSON.MarshalIndentJSON(Conf, "", " ")
|
||||||
confPath := filepath.Join(util.ConfDir, "conf.json")
|
confPath := filepath.Join(util.ConfDir, "conf.json")
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/siyuan-note/filelock"
|
"github.com/siyuan-note/filelock"
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||||
|
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||||
"github.com/siyuan-note/siyuan/kernel/task"
|
"github.com/siyuan-note/siyuan/kernel/task"
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
@ -53,6 +54,14 @@ func autoOCRAssets() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanNotExistAssetsTexts()
|
cleanNotExistAssetsTexts()
|
||||||
|
|
||||||
|
// 刷新 OCR 结果到数据库
|
||||||
|
util.NodeOCRQueueLock.Lock()
|
||||||
|
defer util.NodeOCRQueueLock.Unlock()
|
||||||
|
for _, id := range util.NodeOCRQueue {
|
||||||
|
sql.IndexNodeQueue(id)
|
||||||
|
}
|
||||||
|
util.NodeOCRQueue = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func cleanNotExistAssetsTexts() {
|
func cleanNotExistAssetsTexts() {
|
||||||
|
@ -800,13 +800,13 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
|
|||||||
markdown = treenode.ExportNodeStdMd(n, luteEngine)
|
markdown = treenode.ExportNodeStdMd(n, luteEngine)
|
||||||
|
|
||||||
if !treenode.IsNodeOCRed(n) {
|
if !treenode.IsNodeOCRed(n) {
|
||||||
IndexNodeQueue(n.ID)
|
util.PushNodeOCRQueue(n.ID)
|
||||||
}
|
}
|
||||||
content = treenode.NodeStaticContent(n, nil, true, indexAssetPath)
|
content = treenode.NodeStaticContent(n, nil, true, indexAssetPath)
|
||||||
fc := treenode.FirstLeafBlock(n)
|
fc := treenode.FirstLeafBlock(n)
|
||||||
|
|
||||||
if !treenode.IsNodeOCRed(fc) {
|
if !treenode.IsNodeOCRed(fc) {
|
||||||
IndexNodeQueue(fc.ID)
|
util.PushNodeOCRQueue(fc.ID)
|
||||||
}
|
}
|
||||||
fcontent = treenode.NodeStaticContent(fc, nil, true, false)
|
fcontent = treenode.NodeStaticContent(fc, nil, true, false)
|
||||||
|
|
||||||
@ -820,7 +820,7 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
|
|||||||
markdown = treenode.ExportNodeStdMd(n, luteEngine)
|
markdown = treenode.ExportNodeStdMd(n, luteEngine)
|
||||||
|
|
||||||
if !treenode.IsNodeOCRed(n) {
|
if !treenode.IsNodeOCRed(n) {
|
||||||
IndexNodeQueue(n.ID)
|
util.PushNodeOCRQueue(n.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
content = treenode.NodeStaticContent(n, nil, true, indexAssetPath)
|
content = treenode.NodeStaticContent(n, nil, true, indexAssetPath)
|
||||||
|
@ -273,3 +273,14 @@ func getTesseractLangs() (ret []string) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
NodeOCRQueue []string
|
||||||
|
NodeOCRQueueLock = sync.Mutex{}
|
||||||
|
)
|
||||||
|
|
||||||
|
func PushNodeOCRQueue(id string) {
|
||||||
|
NodeOCRQueueLock.Lock()
|
||||||
|
defer NodeOCRQueueLock.Unlock()
|
||||||
|
NodeOCRQueue = append(NodeOCRQueue, id)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user