mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-21 17:46:48 +00:00
fix(GODT-2442): Handle event poll not starting after resync
It is possible, on slower machines, that the new event poll task is not yet registered and attempts to cancel have nothing to cancel. In this case, we need the refresh event to cancel the task, at that point it is guaranteed that the task exists.
This commit is contained in:
@ -93,10 +93,10 @@ func (user *User) handleRefreshEvent(ctx context.Context, refresh proton.Refresh
|
||||
// Re-sync messages after the user, address and label refresh.
|
||||
defer user.goSync()
|
||||
|
||||
return user.syncUserAddressesLabelsAndClearSync(ctx)
|
||||
return user.syncUserAddressesLabelsAndClearSync(ctx, false)
|
||||
}
|
||||
|
||||
func (user *User) syncUserAddressesLabelsAndClearSync(ctx context.Context) error {
|
||||
func (user *User) syncUserAddressesLabelsAndClearSync(ctx context.Context, cancelEventPool bool) error {
|
||||
return safe.LockRet(func() error {
|
||||
// Fetch latest user info.
|
||||
apiUser, err := user.client.GetUser(ctx)
|
||||
@ -128,7 +128,8 @@ func (user *User) syncUserAddressesLabelsAndClearSync(ctx context.Context) error
|
||||
|
||||
// The user was refreshed.
|
||||
user.eventCh.Enqueue(events.UserRefreshed{
|
||||
UserID: user.apiUser.ID,
|
||||
UserID: user.apiUser.ID,
|
||||
CancelEventPool: cancelEventPool,
|
||||
})
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user