mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-16 07:06:45 +00:00
fix(GODT-2951): Negative WaitGroup Counter
Do not defer call to `wg.Done()` in `job.onJobFinished`. If there is an error it will also call `wg.Done()`.
This commit is contained in:
@ -113,13 +113,14 @@ func (j *Job) onStageCompleted(ctx context.Context, count int64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (j *Job) onJobFinished(ctx context.Context, lastMessageID string, count int64) {
|
func (j *Job) onJobFinished(ctx context.Context, lastMessageID string, count int64) {
|
||||||
defer j.wg.Done()
|
|
||||||
|
|
||||||
if err := j.state.SetLastMessageID(ctx, lastMessageID, count); err != nil {
|
if err := j.state.SetLastMessageID(ctx, lastMessageID, count); err != nil {
|
||||||
j.log.WithError(err).Error("Failed to store last synced message id")
|
j.log.WithError(err).Error("Failed to store last synced message id")
|
||||||
j.onError(err)
|
j.onError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// j.onError() also calls j.wg.Done().
|
||||||
|
j.wg.Done()
|
||||||
j.syncReporter.OnProgress(ctx, count)
|
j.syncReporter.OnProgress(ctx, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user