From 27bdcb6672f7b9cd4cc9bda1cdeb8c2171dad57d Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 26 Jun 2022 20:14:27 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=94=B9=E8=BF=9B=E6=A1=8C=E9=9D=A2?= =?UTF-8?q?=E7=AB=AF=E5=BA=95=E9=83=A8=E7=8A=B6=E6=80=81=E6=A0=8F=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=20https://github.com/siyuan-note/siyuan/issues/5294?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/repository.go | 20 +++++++++++++------- kernel/util/websocket.go | 2 ++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/kernel/model/repository.go b/kernel/model/repository.go index a4a964987..e42b09a37 100644 --- a/kernel/model/repository.go +++ b/kernel/model/repository.go @@ -402,13 +402,19 @@ func indexRepoBeforeCloudSync() { return } elapsed := time.Since(start) - if nil != latest && latest.ID != index.ID { - // 对新创建的快照需要更新备注,加入耗时统计 - index.Memo = fmt.Sprintf("[Auto] Cloud sync, completed in [%.2fs]", elapsed.Seconds()) - err = repo.PutIndex(index) - if nil != err { - util.LogErrorf("put index into data repo before cloud sync failed: %s", err) - return + if nil != latest { + if latest.ID != index.ID { + // 对新创建的快照需要更新备注,加入耗时统计 + index.Memo = fmt.Sprintf("[Auto] Cloud sync, completed in [%.2fs]", elapsed.Seconds()) + err = repo.PutIndex(index) + if nil != err { + util.PushStatusBar("Save data snapshot for cloud sync failed") + util.LogErrorf("put index into data repo before cloud sync failed: %s", err) + return + } + util.PushStatusBar("Made a new data snapshot for cloud sync") + } else { + util.PushStatusBar("Checked data snapshot and found no changes ") } } if 7000 < elapsed.Milliseconds() { diff --git a/kernel/util/websocket.go b/kernel/util/websocket.go index b3eda3aad..ad2bcf8a1 100644 --- a/kernel/util/websocket.go +++ b/kernel/util/websocket.go @@ -18,6 +18,7 @@ package util import ( "sync" + "time" "github.com/88250/gulu" "github.com/88250/melody" @@ -145,6 +146,7 @@ func PushErrMsg(msg string, timeout int) (msgId string) { } func PushStatusBar(msg string) { + msg += " (" + time.Now().Format("2006-01-02 15:04:05") + ")" BroadcastByType("main", "statusbar", 0, msg, nil) }