mirror of
https://github.com/warmbly/warmbly.git
synced 2026-09-06 00:01:24 +00:00
Merge pull request #180 from joaoppa/fix/165-imap-release-mailbox
fix: release the selected IMAP mailbox before the LIST-STATUS poll so live sync keeps detecting new mail on Dovecot
This commit is contained in:
@@ -33,6 +33,9 @@ func (w *WMail) Sync(ctx context.Context) *errx.MailError {
|
||||
stats := &tickStats{}
|
||||
|
||||
client := w.SmtpImapData.ImapClient
|
||||
// A mailbox left selected by the previous pass freezes LIST-STATUS on this
|
||||
// connection, so release it before asking what changed.
|
||||
client.ReleaseMailbox()
|
||||
folders, err := client.Folders()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -193,6 +193,17 @@ func (c *Client) SelectForSync(mailbox string) (uint32, *errx.MailError) {
|
||||
return data.NumMessages, nil
|
||||
}
|
||||
|
||||
// ReleaseMailbox drops the selected mailbox. Dovecot answers LIST-STATUS for
|
||||
// the selected mailbox with the values it held at SELECT, so a loop that keeps
|
||||
// INBOX selected never sees another change land. Servers without UNSELECT keep
|
||||
// the previous behaviour.
|
||||
func (c *Client) ReleaseMailbox() {
|
||||
if c.client == nil || !c.client.Caps().Has(imap.CapUnselect) {
|
||||
return
|
||||
}
|
||||
_ = c.client.Unselect().Wait()
|
||||
}
|
||||
|
||||
// Fetched is one message's envelope as read by FetchEnvelopes, plus what
|
||||
// FetchBody needs to read its text parts later. Bodies are deliberately a
|
||||
// second step: the sync loop decides per message whether it is new and
|
||||
|
||||
Reference in New Issue
Block a user