mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-18 08:06:59 +00:00
fix(GODT-2828): Fix negative report time
This commit is contained in:
@ -58,6 +58,7 @@ func (rep *syncReporter) OnProgress(ctx context.Context, delta int64) {
|
|||||||
rep.count += delta
|
rep.count += delta
|
||||||
|
|
||||||
var progress float64
|
var progress float64
|
||||||
|
var remaining time.Duration
|
||||||
|
|
||||||
// It's possible for count to be bigger or smaller than total depending on when the sync begins and whether new
|
// It's possible for count to be bigger or smaller than total depending on when the sync begins and whether new
|
||||||
// messages are added/removed during this period. When this happens just limited the progress to 100%.
|
// messages are added/removed during this period. When this happens just limited the progress to 100%.
|
||||||
@ -65,6 +66,7 @@ func (rep *syncReporter) OnProgress(ctx context.Context, delta int64) {
|
|||||||
progress = 1
|
progress = 1
|
||||||
} else {
|
} else {
|
||||||
progress = float64(rep.count) / float64(rep.total)
|
progress = float64(rep.count) / float64(rep.total)
|
||||||
|
remaining = time.Since(rep.start) * time.Duration(rep.total-(rep.count+1)) / time.Duration(rep.count+1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if time.Since(rep.last) > rep.freq {
|
if time.Since(rep.last) > rep.freq {
|
||||||
@ -72,7 +74,7 @@ func (rep *syncReporter) OnProgress(ctx context.Context, delta int64) {
|
|||||||
UserID: rep.userID,
|
UserID: rep.userID,
|
||||||
Progress: progress,
|
Progress: progress,
|
||||||
Elapsed: time.Since(rep.start),
|
Elapsed: time.Since(rep.start),
|
||||||
Remaining: time.Since(rep.start) * time.Duration(rep.total-(rep.count+1)) / time.Duration(rep.count+1),
|
Remaining: remaining,
|
||||||
})
|
})
|
||||||
|
|
||||||
rep.last = time.Now()
|
rep.last = time.Now()
|
||||||
|
|||||||
Reference in New Issue
Block a user