From e8fe3a77b352492faf734aa06f508312ad19dc8f Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 24 Jan 2023 21:05:32 +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/model/conf.go | 2 -- kernel/model/transaction.go | 23 +++++++++++++++++++++++ kernel/task/queue.go | 10 ---------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/kernel/model/conf.go b/kernel/model/conf.go index 519a1263c..a8a31ebec 100644 --- a/kernel/model/conf.go +++ b/kernel/model/conf.go @@ -38,7 +38,6 @@ import ( "github.com/siyuan-note/logging" "github.com/siyuan-note/siyuan/kernel/conf" "github.com/siyuan-note/siyuan/kernel/sql" - "github.com/siyuan-note/siyuan/kernel/task" "github.com/siyuan-note/siyuan/kernel/treenode" "github.com/siyuan-note/siyuan/kernel/util" "golang.org/x/text/language" @@ -422,7 +421,6 @@ func Close(force bool, execInstallPkg int) (exitCode int) { } } - task.CloseWait() Conf.Close() sql.CloseDatabase() treenode.SaveBlockTree(false) diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 0b606d13e..f468c3fcf 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -1303,6 +1303,13 @@ func autoFixIndex() { } reindexTreeByPath(box.ID, p, i, size) + if util.IsExiting { + break + } + } + + if util.IsExiting { + break } } @@ -1347,6 +1354,10 @@ func autoFixIndex() { logging.LogWarnf("exist more than one tree [%s], reindex it", rootID) sql.RemoveTreeQueue(root.Box, rootID) reindexTree(rootID, i, size) + + if util.IsExiting { + break + } } util.PushStatusBar(Conf.Language(185)) @@ -1358,6 +1369,10 @@ func reindexTreeByUpdated(rootUpdatedMap, dbRootUpdatedMap map[string]string, bl for rootID, updated := range rootUpdatedMap { i++ + if util.IsExiting { + break + } + rootUpdated := dbRootUpdatedMap[rootID] if "" == rootUpdated { logging.LogWarnf("not found tree [%s] in database, reindex it", rootID) @@ -1378,6 +1393,10 @@ func reindexTreeByUpdated(rootUpdatedMap, dbRootUpdatedMap map[string]string, bl reindexTree(rootID, i, size) continue } + + if util.IsExiting { + break + } } for rootID, _ := range dbRootUpdatedMap { @@ -1385,6 +1404,10 @@ func reindexTreeByUpdated(rootUpdatedMap, dbRootUpdatedMap map[string]string, bl logging.LogWarnf("tree [%s] is not in block tree, remove it from [%s]", rootID, blocksTable) sql.DeleteTree(blocksTable, rootID) } + + if util.IsExiting { + break + } } } diff --git a/kernel/task/queue.go b/kernel/task/queue.go index fc4c6226f..6d8c63bf7 100644 --- a/kernel/task/queue.go +++ b/kernel/task/queue.go @@ -161,16 +161,6 @@ func Loop() { } } -func CloseWait() { - taskQueueStatus = QueueStatusClosing - for { - time.Sleep(10 * time.Millisecond) - if 1 > len(taskQueue) { - break - } - } -} - func clearQueue() { queueLock.Lock() defer queueLock.Unlock()