🎨 优化同步日志

This commit is contained in:
Liang Ding 2022-07-28 10:52:29 +08:00
parent 10d61bb257
commit 297e40f628
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
8 changed files with 22 additions and 20 deletions

View file

@ -453,7 +453,7 @@ func RefreshFileTree() {
WaitForWritingFiles()
if err := sql.InitDatabase(true); nil != err {
util.PushErrMsg(Conf.Language(85), 5000)
util.PushErrMsg(fmt.Sprintf(Conf.Language(85), err), 5000)
return
}

View file

@ -465,7 +465,7 @@ func IndexRepo(memo string) (err error) {
return
}
func syncRepo(boot, exit, byHand bool) {
func syncRepo(boot, exit, byHand bool) (err error) {
if 1 > len(Conf.Repo.Key) {
syncDownloadErrCount++
planSyncAfter(fixSyncInterval)
@ -591,9 +591,9 @@ func indexRepoBeforeCloudSync(repo *dejavu.Repo) (index *entity.Index, err error
dejavu.CtxPushMsg: dejavu.CtxPushMsgToStatusBar,
})
if nil != err {
msg := fmt.Sprintf(Conf.Language(140), err)
msg := fmt.Sprintf(Conf.Language(140), formatErrorMsg(err))
util.PushStatusBar(msg)
util.PushErrMsg(msg, 5000)
util.PushErrMsg(msg, 12000)
logging.LogErrorf("index data repo before cloud sync failed: %s", err)
return
}

View file

@ -110,15 +110,17 @@ func SyncData(boot, exit, byHand bool) {
Conf.Sync.Synced = now
util.BroadcastByType("main", "syncing", 0, Conf.Language(81), nil)
defer func() {
synced := util.Millisecond2Time(Conf.Sync.Synced).Format("2006-01-02 15:04:05") + "\n\n" + Conf.Sync.Stat
msg := fmt.Sprintf(Conf.Language(82), synced)
Conf.Sync.Stat = msg
Conf.Save()
util.BroadcastByType("main", "syncing", 1, msg, nil)
}()
syncRepo(boot, exit, byHand)
err := syncRepo(boot, exit, byHand)
synced := util.Millisecond2Time(Conf.Sync.Synced).Format("2006-01-02 15:04:05") + "\n\n"
if nil == err {
synced += Conf.Sync.Stat
} else {
synced += fmt.Sprintf(Conf.Language(80), err)
}
msg := fmt.Sprintf(Conf.Language(82), synced)
Conf.Sync.Stat = msg
Conf.Save()
util.BroadcastByType("main", "syncing", 1, msg, nil)
return
}
@ -324,8 +326,8 @@ func formatErrorMsg(err error) string {
msgLowerCase := strings.ToLower(msg)
if strings.Contains(msgLowerCase, "permission denied") || strings.Contains(msg, "access is denied") {
msg = Conf.Language(33) + " " + err.Error()
} else if strings.Contains(msgLowerCase, "device or resource busy") {
msg = Conf.Language(85) + " " + err.Error()
} else if strings.Contains(msgLowerCase, "device or resource busy") || strings.Contains(msg, "is being used by another") {
msg = fmt.Sprintf(Conf.Language(85), err)
} else if strings.Contains(msgLowerCase, "cipher: message authentication failed") {
msg = Conf.Language(172) + " " + err.Error()
} else if strings.Contains(msgLowerCase, "repo fatal error") {