From 2d94fd2b76050f720ed626897df5069a206d3d36 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 18 Jan 2023 23:05:13 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=94=B9=E8=BF=9B=E5=86=85=E6=A0=B8?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=B0=83=E5=BA=A6=E6=9C=BA=E5=88=B6=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E7=A8=B3=E5=AE=9A=E6=80=A7=20https://github.com/siyua?= =?UTF-8?q?n-note/siyuan/issues/7113?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/main.go | 2 +- kernel/mobile/kernel.go | 2 +- kernel/model/ocr.go | 5 +++-- kernel/sql/queue.go | 7 ++++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/kernel/main.go b/kernel/main.go index 426622bd8..caf2dd1c7 100644 --- a/kernel/main.go +++ b/kernel/main.go @@ -52,7 +52,7 @@ func main() { util.PushClearAllMsg() go model.AutoRefreshCheck() go model.AutoFlushTx() - go sql.AutoFlushQueue() + go sql.AutoFlushTx() go treenode.AutoFlushBlockTree() go cache.LoadAssets() go model.AutoFixIndex() diff --git a/kernel/mobile/kernel.go b/kernel/mobile/kernel.go index 67b339a1d..c043809dc 100644 --- a/kernel/mobile/kernel.go +++ b/kernel/mobile/kernel.go @@ -66,7 +66,7 @@ func StartKernel(container, appDir, workspaceBaseDir, timezoneID, localIPs, lang util.PushClearAllMsg() go model.AutoRefreshCheck() go model.AutoFlushTx() - go sql.AutoFlushQueue() + go sql.AutoFlushTx() go treenode.AutoFlushBlockTree() go cache.LoadAssets() go model.AutoFixIndex() diff --git a/kernel/model/ocr.go b/kernel/model/ocr.go index 19cc77dae..740145e4d 100644 --- a/kernel/model/ocr.go +++ b/kernel/model/ocr.go @@ -1,7 +1,6 @@ package model import ( - "github.com/dustin/go-humanize" "io" "os" "path/filepath" @@ -12,9 +11,11 @@ import ( "time" "github.com/88250/gulu" + "github.com/dustin/go-humanize" "github.com/panjf2000/ants/v2" "github.com/siyuan-note/logging" "github.com/siyuan-note/siyuan/kernel/cache" + "github.com/siyuan-note/siyuan/kernel/task" "github.com/siyuan-note/siyuan/kernel/util" ) @@ -24,7 +25,7 @@ func AutoOCRAssets() { } for { - autoOCRAssets() + task.AppendTask(task.OCRImage, autoOCRAssets) time.Sleep(7 * time.Second) } } diff --git a/kernel/sql/queue.go b/kernel/sql/queue.go index c9c71cfa2..2b076f97c 100644 --- a/kernel/sql/queue.go +++ b/kernel/sql/queue.go @@ -29,6 +29,7 @@ import ( "github.com/emirpasic/gods/sets/hashset" "github.com/siyuan-note/eventbus" "github.com/siyuan-note/logging" + "github.com/siyuan-note/siyuan/kernel/task" "github.com/siyuan-note/siyuan/kernel/util" ) @@ -50,10 +51,10 @@ type treeQueueOperation struct { renameTreeOldHPath string // rename } -func AutoFlushTreeQueue() { +func AutoFlushTx() { for { - flushTreeQueue() time.Sleep(util.SQLFlushInterval) + task.PrependTask(task.DatabaseIndex, FlushQueue) } } @@ -91,7 +92,7 @@ func ClearQueue() { operationQueue = nil } -func flushTreeQueue() { +func FlushQueue() { ops := mergeUpsertTrees() if 1 > len(ops) { return