diff options
author | kt programs <ktprograms@gmail.com> | 2022-09-25 09:55:21 +0800 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-09-29 17:14:07 +0200 |
commit | 9c0e54f9d9afb5f4a9d91ca9766fc2ef2cfd82de (patch) | |
tree | 2e2e6fd94233c3cb73d2b7fe9797ec603d9ff461 /worker/imap/checkmail.go | |
parent | bf2bf8c242cbddce684acd55743caa9b749f6d46 (diff) | |
download | aerc-9c0e54f9d9afb5f4a9d91ca9766fc2ef2cfd82de.tar.gz |
imap: stop checkmail if there are pending actions
Pass message containing remaining directories to check. Account widget
will recursively call CheckMail with the remaining directories until
a Done message is returned.
Only needed for IMAP worker as other workers run check-mail-cmd in
a separate goroutine.
Suggested-By: Tim Culverhouse <tim@timculverhouse.com>
Signed-off-by: kt programs <ktprograms@gmail.com>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'worker/imap/checkmail.go')
-rw-r--r-- | worker/imap/checkmail.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/worker/imap/checkmail.go b/worker/imap/checkmail.go index 21f2e4bb..e0aef71b 100644 --- a/worker/imap/checkmail.go +++ b/worker/imap/checkmail.go @@ -13,7 +13,13 @@ func (w *IMAPWorker) handleCheckMailMessage(msg *types.CheckMail) { imap.StatusRecent, imap.StatusUnseen, } + var remaining []string for _, dir := range msg.Directories { + if len(w.worker.Actions) > 0 { + remaining = append(remaining, dir) + continue + } + logging.Debugf("Getting status of directory %s", dir) status, err := w.client.Status(dir, items) if err != nil { @@ -38,5 +44,12 @@ func (w *IMAPWorker) handleCheckMailMessage(msg *types.CheckMail) { }, nil) } } + if len(remaining) > 0 { + w.worker.PostMessage(&types.CheckMailDirectories{ + Message: types.RespondTo(msg), + Directories: remaining, + }, nil) + return + } w.worker.PostMessage(&types.Done{Message: types.RespondTo(msg)}, nil) } |