Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Dec 9, 2023
2 parents 5fac682 + ba547e0 commit db2a3a5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
8 changes: 4 additions & 4 deletions kernel/model/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,15 +586,13 @@ func NewLute() (ret *lute.Lute) {
return
}

var confSaveLock = sync.Mutex{}

func (conf *AppConf) Save() {
if util.ReadOnly {
return
}

confSaveLock.Lock()
defer confSaveLock.Unlock()
Conf.m.Lock()
defer Conf.m.Unlock()

newData, _ := gulu.JSON.MarshalIndentJSON(Conf, "", " ")
confPath := filepath.Join(util.ConfDir, "conf.json")
Expand Down Expand Up @@ -949,6 +947,7 @@ func upgradeUserGuide() {
continue
}

logging.LogInfof("upgrading user guide box [%s]", boxID)
unindex(boxID)

if err = filelock.Remove(boxDirPath); nil != err {
Expand All @@ -960,6 +959,7 @@ func upgradeUserGuide() {
}

index(boxID)
logging.LogInfof("upgraded user guide box [%s]", boxID)
}
}

Expand Down
9 changes: 9 additions & 0 deletions kernel/model/ocr.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/logging"
"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/util"
)
Expand Down Expand Up @@ -53,6 +54,14 @@ func autoOCRAssets() {
}

cleanNotExistAssetsTexts()

// 刷新 OCR 结果到数据库
util.NodeOCRQueueLock.Lock()
defer util.NodeOCRQueueLock.Unlock()
for _, id := range util.NodeOCRQueue {
sql.IndexNodeQueue(id)
}
util.NodeOCRQueue = nil
}

func cleanNotExistAssetsTexts() {
Expand Down
6 changes: 3 additions & 3 deletions kernel/sql/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -800,13 +800,13 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
markdown = treenode.ExportNodeStdMd(n, luteEngine)

if !treenode.IsNodeOCRed(n) {
IndexNodeQueue(n.ID)
util.PushNodeOCRQueue(n.ID)
}
content = treenode.NodeStaticContent(n, nil, true, indexAssetPath)
fc := treenode.FirstLeafBlock(n)

if !treenode.IsNodeOCRed(fc) {
IndexNodeQueue(fc.ID)
util.PushNodeOCRQueue(fc.ID)
}
fcontent = treenode.NodeStaticContent(fc, nil, true, false)

Expand All @@ -820,7 +820,7 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
markdown = treenode.ExportNodeStdMd(n, luteEngine)

if !treenode.IsNodeOCRed(n) {
IndexNodeQueue(n.ID)
util.PushNodeOCRQueue(n.ID)
}

content = treenode.NodeStaticContent(n, nil, true, indexAssetPath)
Expand Down
11 changes: 11 additions & 0 deletions kernel/util/tesseract.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,14 @@ func getTesseractLangs() (ret []string) {
}
return
}

var (
NodeOCRQueue []string
NodeOCRQueueLock = sync.Mutex{}
)

func PushNodeOCRQueue(id string) {
NodeOCRQueueLock.Lock()
defer NodeOCRQueueLock.Unlock()
NodeOCRQueue = append(NodeOCRQueue, id)
}

0 comments on commit db2a3a5

Please sign in to comment.