Skip to content

Commit

Permalink
fix(GODT-2400): Allow state updates to be applied if command fails
Browse files Browse the repository at this point in the history
In the case there is an unexpected issue with the IMAP command, still
allow pending state updates to be applied.
  • Loading branch information
LBeernaertProton committed Feb 27, 2023
1 parent ad146e4 commit 45c83ff
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/session/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,18 @@ func (s *Session) handleSelectedCommand(

return s.state.Selected(ctx, func(mailbox *state.Mailbox) error {
okResponse, err := s.handleWithMailbox(ctx, tag, cmd, mailbox, ch)
if err != nil {
return err

// Allow state updates to be applied if the command failed. It might resolve
// some invalid state problem.
if flushErr := flush(ctx, mailbox, false, ch); flushErr != nil {
if err != nil {
return fmt.Errorf("%w (flush err:%v)", err, flushErr)
}

return flushErr
}

if err := flush(ctx, mailbox, false, ch); err != nil {
if err != nil {
return err
}

Expand Down

0 comments on commit 45c83ff

Please sign in to comment.