From 025cab9ec39d3b69e53c8c3647e1f9402613c1dd Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 7 Jul 2022 22:15:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?:art:=20=E4=B8=8D=E8=BD=AC=E4=B9=89?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/util/websocket.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/kernel/util/websocket.go b/kernel/util/websocket.go index 90cbbd0b4..ad2bcf8a1 100644 --- a/kernel/util/websocket.go +++ b/kernel/util/websocket.go @@ -21,7 +21,6 @@ import ( "time" "github.com/88250/gulu" - "github.com/88250/lute/html" "github.com/88250/melody" ) @@ -126,33 +125,28 @@ func ReloadUI() { } func PushTxErr(msg string, code int, data interface{}) { - msg = html.EscapeHTMLStr(msg) BroadcastByType("main", "txerr", code, msg, data) } func PushUpdateMsg(msgId string, msg string, timeout int) { - msg = html.EscapeHTMLStr(msg) BroadcastByType("main", "msg", 0, msg, map[string]interface{}{"id": msgId, "closeTimeout": timeout}) return } func PushMsg(msg string, timeout int) (msgId string) { msgId = gulu.Rand.String(7) - msg = html.EscapeHTMLStr(msg) BroadcastByType("main", "msg", 0, msg, map[string]interface{}{"id": msgId, "closeTimeout": timeout}) return } func PushErrMsg(msg string, timeout int) (msgId string) { msgId = gulu.Rand.String(7) - msg = html.EscapeHTMLStr(msg) BroadcastByType("main", "msg", -1, msg, map[string]interface{}{"id": msgId, "closeTimeout": timeout}) return } func PushStatusBar(msg string) { msg += " (" + time.Now().Format("2006-01-02 15:04:05") + ")" - msg = html.EscapeHTMLStr(msg) BroadcastByType("main", "statusbar", 0, msg, nil) } From 851c787f3f74d2389201cea8ba08f41e37a77439 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 7 Jul 2022 22:50:45 +0800 Subject: [PATCH 2/2] :art: logging --- kernel/filesys/tree.go | 4 ++-- kernel/model/repository.go | 34 ++++++++++++++++++---------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/kernel/filesys/tree.go b/kernel/filesys/tree.go index 61aa44c7b..fcb72bc6b 100644 --- a/kernel/filesys/tree.go +++ b/kernel/filesys/tree.go @@ -73,13 +73,13 @@ func LoadTree(boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err erro parentPath = filepath.Join(util.DataDir, boxID, parentPath) parentData, readErr := filelock.LockFileRead(parentPath) if nil != readErr { - util.LogWarnf("read tree data [%s] failed: %s", parentPath, err) + util.LogWarnf("read tree data [%s] failed: %s", parentPath, readErr) hPathBuilder.WriteString("Untitled/") continue } parentTree, parseErr := protyle.ParseJSONWithoutFix(luteEngine, parentData) if nil != parseErr { - util.LogWarnf("parse tree [%s] failed: %s", parentPath, err) + util.LogWarnf("parse tree [%s] failed: %s", parentPath, parseErr) hPathBuilder.WriteString("Untitled/") continue } diff --git a/kernel/model/repository.go b/kernel/model/repository.go index a42e6e83d..fb87cf5d5 100644 --- a/kernel/model/repository.go +++ b/kernel/model/repository.go @@ -512,7 +512,9 @@ func indexRepoBeforeCloudSync(repo *dejavu.Repo) (err error) { dejavu.CtxPushMsg: dejavu.CtxPushMsgToStatusBar, }) if nil != err { - util.PushStatusBar(fmt.Sprintf(Conf.Language(140), err)) + msg := fmt.Sprintf(Conf.Language(140), err) + util.PushStatusBar(msg) + util.PushErrMsg(msg, 5000) util.LogErrorf("index data repo before cloud sync failed: %s", err) return } @@ -542,92 +544,92 @@ func newRepository() (ret *dejavu.Repo, err error) { ignoreLines = append(ignoreLines, "/.siyuan/conf.json") // 忽略旧版同步配置 ret, err = dejavu.NewRepo(util.DataDir, util.RepoDir, util.HistoryDir, util.TempDir, Conf.Repo.Key, ignoreLines) if nil != err { - util.LogErrorf("init data repository failed: %s", err) + util.LogErrorf("init data repo failed: %s", err) } return } func subscribeEvents() { eventbus.Subscribe(dejavu.EvtIndexWalkData, func(context map[string]interface{}, path string) { - msg := "Indexing data repository [walk data " + path + "]" + msg := "Indexing data repo [walk data " + path + "]" util.SetBootDetails(msg) contextPushMsg(context, msg) }) eventbus.Subscribe(dejavu.EvtIndexGetLatestFile, func(context map[string]interface{}, path string) { - msg := "Indexing data repository [get latest file " + path + "]" + msg := "Indexing data repo [get latest file " + path + "]" util.SetBootDetails(msg) contextPushMsg(context, msg) }) eventbus.Subscribe(dejavu.EvtIndexUpsertFile, func(context map[string]interface{}, path string) { - msg := "Indexing data repository [upsert file " + path + "]" + msg := "Indexing data repo [upsert file " + path + "]" util.SetBootDetails(msg) contextPushMsg(context, msg) }) eventbus.Subscribe(dejavu.EvtCheckoutWalkData, func(context map[string]interface{}, path string) { - msg := "Checkout data repository [walk data " + path + "]" + msg := "Checkout data repo [walk data " + path + "]" util.SetBootDetails(msg) contextPushMsg(context, msg) }) eventbus.Subscribe(dejavu.EvtCheckoutUpsertFile, func(context map[string]interface{}, path string) { - msg := "Checkout data repository [upsert file " + path + "]" + msg := "Checkout data repo [upsert file " + path + "]" util.SetBootDetails(msg) contextPushMsg(context, msg) }) eventbus.Subscribe(dejavu.EvtCheckoutRemoveFile, func(context map[string]interface{}, path string) { - msg := "Checkout data repository [remove file " + path + "]" + msg := "Checkout data repo [remove file " + path + "]" util.SetBootDetails(msg) contextPushMsg(context, msg) }) eventbus.Subscribe(dejavu.EvtCloudBeforeDownloadIndex, func(context map[string]interface{}, id string) { - msg := "Downloading data repository index [" + id + "]" + msg := "Downloading data repo index [" + id + "]" util.SetBootDetails(msg) contextPushMsg(context, msg) }) eventbus.Subscribe(dejavu.EvtCloudBeforeDownloadFile, func(context map[string]interface{}, id string) { - msg := "Downloading data repository file [" + id + "]" + msg := "Downloading data repo file [" + id + "]" util.SetBootDetails(msg) contextPushMsg(context, msg) //util.LogInfof("%s", msg) }) eventbus.Subscribe(dejavu.EvtCloudBeforeDownloadChunk, func(context map[string]interface{}, id string) { - msg := "Downloading data repository chunk [" + id + "]" + msg := "Downloading data repo chunk [" + id + "]" util.SetBootDetails(msg) contextPushMsg(context, msg) //util.LogInfof("%s", msg) }) eventbus.Subscribe(dejavu.EvtCloudBeforeDownloadRef, func(context map[string]interface{}, ref string) { - msg := "Downloading data repository ref [" + ref + "]" + msg := "Downloading data repo ref [" + ref + "]" util.SetBootDetails(msg) contextPushMsg(context, msg) }) eventbus.Subscribe(dejavu.EvtCloudBeforeUploadIndex, func(context map[string]interface{}, id string) { - msg := "Uploading data repository index [" + id + "]" + msg := "Uploading data repo index [" + id + "]" util.SetBootDetails(msg) contextPushMsg(context, msg) }) eventbus.Subscribe(dejavu.EvtCloudBeforeUploadFile, func(context map[string]interface{}, id string) { - msg := "Uploading data repository file [" + id + "]" + msg := "Uploading data repo file [" + id + "]" util.SetBootDetails(msg) contextPushMsg(context, msg) //util.LogInfof("%s", msg) }) eventbus.Subscribe(dejavu.EvtCloudBeforeUploadChunk, func(context map[string]interface{}, id string) { - msg := "Uploading data repository chunk [" + id + "]" + msg := "Uploading data repo chunk [" + id + "]" util.SetBootDetails(msg) contextPushMsg(context, msg) //util.LogInfof("%s", msg) }) eventbus.Subscribe(dejavu.EvtCloudBeforeUploadRef, func(context map[string]interface{}, ref string) { - msg := "Uploading data repository ref [" + ref + "]" + msg := "Uploading data repo ref [" + ref + "]" util.SetBootDetails(msg) contextPushMsg(context, msg) })