Skip to content

Commit d07fab9

Browse files
authored
fix uncorrect progress add. (#614)
* update trigger const. * feat: implement more accurate progress. * optimize method implement. * update conversation List logic. * update method logic. * update conversation logic. * update BatchInsertMessageList. * update addProgress to private. * fix update loss contents. * update condition logic. * fix: remove uncorrect use ctx. * remove unnecesary content. * fix:remove uncorrect log call. * fix uncorrect progress add. * recovery.
1 parent 70b99c1 commit d07fab9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

internal/conversation_msg/conversation_msg.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,8 @@ func (c *Conversation) doMsgSyncByReinstalled(c2v common.Cmd2Value) {
531531
}
532532
log.ZDebug(ctx, "before trigger msg", "cost time", time.Since(b).Seconds(), "len", len(allMsg))
533533

534-
c.addProgress(msgLen / total * 90)
534+
c.addProgress((msgLen * 90) / total)
535535
c.ConversationListener().OnSyncServerProgress(c.getProgress())
536-
537536
}
538537

539538
func (c *Conversation) addProgress(progress int) {

internal/conversation_msg/conversation_notification.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ func (c *Conversation) Work(c2v common.Cmd2Value) {
6565
func (c *Conversation) syncFlag(c2v common.Cmd2Value) {
6666
ctx := c2v.Ctx
6767
syncFlag := c2v.Value.(sdk_struct.CmdNewMsgComeToConversation).SyncFlag
68+
initSyncBaseProgress := 5
6869
switch syncFlag {
6970
case constant.AppDataSyncStart:
7071
log.ZDebug(ctx, "AppDataSyncStart")
@@ -75,7 +76,7 @@ func (c *Conversation) syncFlag(c2v common.Cmd2Value) {
7576
c.friend.IncrSyncFriends,
7677
}
7778
runSyncFunctions(ctx, asyncWaitFunctions, asyncWait)
78-
c.addProgress(4) // add 4 percent in progress
79+
c.addProgress(initSyncBaseProgress)
7980
c.ConversationListener().OnSyncServerProgress(c.getProgress()) // notify server current Progress
8081

8182
syncWaitFunctions := []func(c context.Context) error{
@@ -84,7 +85,7 @@ func (c *Conversation) syncFlag(c2v common.Cmd2Value) {
8485
}
8586
runSyncFunctions(ctx, syncWaitFunctions, syncWait)
8687
log.ZWarn(ctx, "core data sync over", nil, "cost time", time.Since(c.startTime).Seconds())
87-
c.addProgress(6) // add 6 percent in progress
88+
c.addProgress(initSyncBaseProgress)
8889
c.ConversationListener().OnSyncServerProgress(c.getProgress()) // notify server current Progress
8990

9091
asyncNoWaitFunctions := []func(c context.Context) error{

0 commit comments

Comments
 (0)