diff options
-rw-r--r-- | worker/imap/fetch.go | 12 | ||||
-rw-r--r-- | worker/imap/list.go | 14 |
2 files changed, 26 insertions, 0 deletions
diff --git a/worker/imap/fetch.go b/worker/imap/fetch.go index 74108135..0c923bf0 100644 --- a/worker/imap/fetch.go +++ b/worker/imap/fetch.go @@ -19,6 +19,12 @@ import ( func (imapw *IMAPWorker) handleFetchMessageHeaders( msg *types.FetchMessageHeaders, ) { + if msg.Context.Err() != nil { + imapw.worker.PostMessage(&types.Cancelled{ + Message: types.RespondTo(msg), + }, nil) + return + } toFetch := msg.Uids if imapw.config.cacheEnabled && imapw.cache != nil { toFetch = imapw.getCachedHeaders(msg) @@ -210,6 +216,12 @@ func (imapw *IMAPWorker) handleFetchMessageFlags(msg *types.FetchMessageFlags) { imap.FetchFlags, imap.FetchUid, } + if msg.Context.Err() != nil { + imapw.worker.PostMessage(&types.Cancelled{ + Message: types.RespondTo(msg), + }, nil) + return + } imapw.handleFetchMessages(msg, msg.Uids, items, func(_msg *imap.Message) error { imapw.worker.PostMessage(&types.MessageInfo{ diff --git a/worker/imap/list.go b/worker/imap/list.go index a3469c72..fc1d7e94 100644 --- a/worker/imap/list.go +++ b/worker/imap/list.go @@ -121,12 +121,26 @@ func (imapw *IMAPWorker) handleSearchDirectory(msg *types.SearchDirectory) { return } + if msg.Context.Err() != nil { + imapw.worker.PostMessage(&types.Cancelled{ + Message: types.RespondTo(msg), + }, nil) + return + } + uids, err := imapw.client.UidSearch(criteria) if err != nil { emitError(err) return } + if msg.Context.Err() != nil { + imapw.worker.PostMessage(&types.Cancelled{ + Message: types.RespondTo(msg), + }, nil) + return + } + imapw.worker.PostMessage(&types.SearchResults{ Message: types.RespondTo(msg), Uids: uids, |