diff --git a/internal/bridge/imap.go b/internal/bridge/imap.go index 361e75d9..052eba57 100644 --- a/internal/bridge/imap.go +++ b/internal/bridge/imap.go @@ -140,7 +140,7 @@ func (bridge *Bridge) addIMAPUser(ctx context.Context, user *user.User) error { if err := user.ClearSyncStatus(); err != nil { return fmt.Errorf("failed to clear sync status: %w", err) } - + // Add the user back to the IMAP server. if isNew, err := bridge.imapServer.LoadUser(ctx, imapConn, gluonID, user.GluonKey()); err != nil { return fmt.Errorf("failed to add IMAP user: %w", err) diff --git a/internal/user/user.go b/internal/user/user.go index b500319c..3b1c168d 100644 --- a/internal/user/user.go +++ b/internal/user/user.go @@ -196,15 +196,7 @@ func New( if err := user.doSync(ctx); err != nil { user.log.WithError(err).Error("Failed to sync, will retry later") - - go func() { - select { - case <-ctx.Done(): - user.log.WithError(err).Warn("Aborting sync retry") - case <-time.After(SyncRetryCooldown): - user.goSync() - } - }() + time.AfterFunc(SyncRetryCooldown, user.goSync) } })