mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 04:36:43 +00:00
fix(GODT-3013): IMAP service getting "stuck"
* Ensure IMAP service sync cancel request waits until the sync has completely cancelled rather than just signaling. It's possible that due the context reset on `group.Cancel` that something may have not have been bookmarked correctly in subsequent sync restarts. * Handle connection lost/restored events in the services. Removes the need to lock bridge users. Which could conflict with other ongoing lock operations. Additionally, it ensure that if one service is blocked it doesn't block the entire bridge. * Revise access to bridge user locks.
This commit is contained in:
@ -223,6 +223,7 @@ func newImpl(
|
||||
EventJitter,
|
||||
5*time.Minute,
|
||||
crashHandler,
|
||||
eventSubscription,
|
||||
)
|
||||
|
||||
addressMode := usertypes.VaultToAddressMode(encVault.AddressMode())
|
||||
@ -554,27 +555,6 @@ func (user *User) CheckAuth(email string, password []byte) (string, error) {
|
||||
return user.identityService.CheckAuth(ctx, email, password)
|
||||
}
|
||||
|
||||
// OnStatusUp is called when the connection goes up.
|
||||
func (user *User) OnStatusUp(ctx context.Context) {
|
||||
user.log.Info("Connection is up")
|
||||
|
||||
user.eventService.Resume()
|
||||
|
||||
if err := user.imapService.ResumeSync(ctx); err != nil {
|
||||
user.log.WithError(err).Error("Failed to resume sync")
|
||||
}
|
||||
}
|
||||
|
||||
// OnStatusDown is called when the connection goes down.
|
||||
func (user *User) OnStatusDown(ctx context.Context) {
|
||||
user.log.Info("Connection is down")
|
||||
|
||||
user.eventService.Pause()
|
||||
if err := user.imapService.CancelSync(ctx); err != nil {
|
||||
user.log.WithError(err).Error("Failed to cancel sync")
|
||||
}
|
||||
}
|
||||
|
||||
// Logout logs the user out from the API.
|
||||
func (user *User) Logout(ctx context.Context, withAPI bool) error {
|
||||
user.log.WithField("withAPI", withAPI).Info("Logging out user")
|
||||
|
||||
Reference in New Issue
Block a user