🎨 云端同步上传大量文件时不新增通知 https://github.com/siyuan-note/siyuan/issues/5112

This commit is contained in:
Liang Ding 2022-06-06 22:12:49 +08:00
parent fad08e85e6
commit 2dd16cac9a
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 7 additions and 1 deletions

View file

@ -388,6 +388,7 @@ func ossUpload(isBackup bool, localDirPath, cloudDirPath, cloudDevice string, bo
if poolSize > len(localUpserts) { if poolSize > len(localUpserts) {
poolSize = len(localUpserts) poolSize = len(localUpserts)
} }
msgId := gulu.Rand.String(7)
p, _ := ants.NewPoolWithFunc(poolSize, func(arg interface{}) { p, _ := ants.NewPoolWithFunc(poolSize, func(arg interface{}) {
defer waitGroup.Done() defer waitGroup.Done()
if nil != uploadErr { if nil != uploadErr {
@ -400,7 +401,7 @@ func ossUpload(isBackup bool, localDirPath, cloudDirPath, cloudDevice string, bo
return return
} }
if needPushProgress { if needPushProgress {
util.PushMsg(fmt.Sprintf(Conf.Language(104), wroteFiles, len(localUpserts)-wroteFiles), 1000*60*10) util.PushUpdateMsg(msgId, fmt.Sprintf(Conf.Language(104), wroteFiles, len(localUpserts)-wroteFiles), 1000*60*10)
} }
if boot { if boot {
msg := fmt.Sprintf("Uploading data to the cloud %d/%d", wroteFiles, len(localUpserts)) msg := fmt.Sprintf("Uploading data to the cloud %d/%d", wroteFiles, len(localUpserts))

View file

@ -127,6 +127,11 @@ func PushTxErr(msg string, code int, data interface{}) {
BroadcastByType("main", "txerr", code, msg, data) BroadcastByType("main", "txerr", code, msg, data)
} }
func PushUpdateMsg(msgId string, msg string, timeout int) {
BroadcastByType("main", "msg", 0, msg, map[string]interface{}{"id": msgId, "closeTimeout": timeout})
return
}
func PushMsg(msg string, timeout int) (msgId string) { func PushMsg(msg string, timeout int) (msgId string) {
msgId = gulu.Rand.String(7) msgId = gulu.Rand.String(7)
BroadcastByType("main", "msg", 0, msg, map[string]interface{}{"id": msgId, "closeTimeout": timeout}) BroadcastByType("main", "msg", 0, msg, map[string]interface{}{"id": msgId, "closeTimeout": timeout})