From 7b41e698e14b0a3535c3af94969e52d898d50fcd Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sat, 18 Feb 2023 14:37:54 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=94=B9=E8=BF=9B=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=A0=8F=E6=98=BE=E7=A4=BA=E5=90=8E=E5=8F=B0=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E8=AE=A1=E6=95=B0=20Fix=20https://github.com?= =?UTF-8?q?/siyuan-note/siyuan/issues/7398?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/index.go | 6 +++--- kernel/sql/queue.go | 11 +++++++++-- kernel/sql/queue_history.go | 15 +++++++++++---- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/kernel/model/index.go b/kernel/model/index.go index ea9ec8282..12a5a939c 100644 --- a/kernel/model/index.go +++ b/kernel/model/index.go @@ -268,7 +268,7 @@ func init() { return } - current := context["current"].(int) + 1 + current := context["current"].(int) total := context["total"] msg := fmt.Sprintf(Conf.Language(90), current, total, blockCount, hash) util.SetBootDetails(msg) @@ -280,7 +280,7 @@ func init() { return } - current := context["current"].(int) + 1 + current := context["current"].(int) total := context["total"] msg := fmt.Sprintf(Conf.Language(93), current, total, rootID) util.SetBootDetails(msg) @@ -292,7 +292,7 @@ func init() { return } - current := context["current"].(int) + 1 + current := context["current"].(int) total := context["total"] msg := fmt.Sprintf(Conf.Language(191), current, total) util.SetBootDetails(msg) diff --git a/kernel/sql/queue.go b/kernel/sql/queue.go index 1fa69de1d..cfc61215e 100644 --- a/kernel/sql/queue.go +++ b/kernel/sql/queue.go @@ -110,6 +110,12 @@ func FlushQueue() { defer enableCache() } + groupOpsTotal := map[string]int{} + for _, op := range ops { + groupOpsTotal[op.action]++ + } + + groupOpsCurrent := map[string]int{} for i, op := range ops { if util.IsExiting { return @@ -120,8 +126,9 @@ func FlushQueue() { return } - context["current"] = i - context["total"] = total + groupOpsCurrent[op.action]++ + context["current"] = groupOpsCurrent[op.action] + context["total"] = groupOpsTotal[op.action] if err = execOp(op, tx, context); nil != err { tx.Rollback() logging.LogErrorf("queue operation failed: %s", err) diff --git a/kernel/sql/queue_history.go b/kernel/sql/queue_history.go index b707c5be8..b3cbfdfea 100644 --- a/kernel/sql/queue_history.go +++ b/kernel/sql/queue_history.go @@ -59,7 +59,13 @@ func FlushHistoryQueue() { defer txLock.Unlock() start := time.Now() - total := len(ops) + groupOpsTotal := map[string]int{} + for _, op := range ops { + groupOpsTotal[op.action]++ + } + + context := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar} + groupOpsCurrent := map[string]int{} for i, op := range ops { if util.IsExiting { return @@ -70,9 +76,10 @@ func FlushHistoryQueue() { return } - context := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar} - context["current"] = i - context["total"] = total + groupOpsCurrent[op.action]++ + context["current"] = groupOpsCurrent[op.action] + context["total"] = groupOpsTotal[op.action] + if err = execHistoryOp(op, tx, context); nil != err { tx.Rollback() logging.LogErrorf("queue operation failed: %s", err)