From 448609d1a8005cb0a233514146737b7946d10479 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 7 Feb 2023 20:35:31 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=9C=AA=E7=99=BB=E5=BD=95=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E4=BA=91=E7=AB=AF=E5=90=8C=E6=AD=A5=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF=20Fix=20?= =?UTF-8?q?https://github.com/siyuan-note/siyuan/issues/7277?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/sync.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/kernel/model/sync.go b/kernel/model/sync.go index f4376d63b..fc3908c5b 100644 --- a/kernel/model/sync.go +++ b/kernel/model/sync.go @@ -62,6 +62,10 @@ func BootSyncData() { return } + if !util.IsOnline() { + return + } + syncLock.Lock() defer syncLock.Unlock() @@ -97,9 +101,13 @@ func SyncData(boot, exit, byHand bool) { func syncData(boot, exit, byHand bool) { defer logging.Recover() - util.BroadcastByType("main", "syncing", 0, Conf.Language(81), nil) if !checkSync(boot, exit, byHand) { - util.BroadcastByType("main", "syncing", 1, "", nil) + return + } + + util.BroadcastByType("main", "syncing", 0, Conf.Language(81), nil) + if !util.IsOnline() { // 这个操作比较耗时,所以要先推送 syncing 事件后再判断网络,这样才能给用户更即时的反馈 + util.BroadcastByType("main", "syncing", 2, Conf.Language(28), nil) return } @@ -173,11 +181,6 @@ func checkSync(boot, exit, byHand bool) bool { planSyncAfter(64 * time.Minute) return false } - - if !util.IsOnline() { - util.BroadcastByType("main", "syncing", 2, Conf.Language(28), nil) - return false - } return true }