🎨 优化同步日志

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

@ -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") {