aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-11-28 21:15:34 -0600
committerRobin Jarry <robin@jarry.cc>2022-12-02 22:59:44 +0100
commitdc7816aa8c6a1e023a33fe15b2ef99a0c5ac551f (patch)
treefe38d2f485cd8f1bc7994293153569dc0b4d3447
parent43b18fe6cebee54a423a9463c5c839e8f4ed2fcf (diff)
downloadaerc-dc7816aa8c6a1e023a33fe15b2ef99a0c5ac551f.tar.gz
imap: simplify error handling in list directories
Simplify the error handling in ListDirectories so the Done message is not within an else statement Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--worker/imap/list.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/worker/imap/list.go b/worker/imap/list.go
index e02d7cbb..a03468ab 100644
--- a/worker/imap/list.go
+++ b/worker/imap/list.go
@@ -32,17 +32,18 @@ func (imapw *IMAPWorker) handleListDirectories(msg *types.ListDirectories) {
done <- nil
}()
- if err := imapw.client.List("", "*", mailboxes); err != nil {
+ err := imapw.client.List("", "*", mailboxes)
+ if err != nil {
<-done
imapw.worker.PostMessage(&types.Error{
Message: types.RespondTo(msg),
Error: err,
}, nil)
- } else {
- <-done
- imapw.worker.PostMessage(
- &types.Done{Message: types.RespondTo(msg)}, nil)
+ return
}
+ <-done
+ imapw.worker.PostMessage(
+ &types.Done{Message: types.RespondTo(msg)}, nil)
}
func canOpen(mbox *imap.MailboxInfo) bool {