summary refs log tree commit diff stats
path: root/worker
diff options
context:
space:
mode:
Diffstat (limited to 'worker')
-rw-r--r--worker/imap/list.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/worker/imap/list.go b/worker/imap/list.go
index 6aecbca..5e282ef 100644
--- a/worker/imap/list.go
+++ b/worker/imap/list.go
@@ -9,6 +9,7 @@ import (
 func (imapw *IMAPWorker) handleListDirectories(msg *types.ListDirectories) {
 	mailboxes := make(chan *imap.MailboxInfo)
 	imapw.worker.Logger.Println("Listing mailboxes")
+	done := make(chan interface{})
 
 	go func() {
 		for mbox := range mailboxes {
@@ -22,9 +23,11 @@ func (imapw *IMAPWorker) handleListDirectories(msg *types.ListDirectories) {
 				Attributes: mbox.Attributes,
 			}, nil)
 		}
+		done <- nil
 	}()
 
 	if err := imapw.client.List("", "*", mailboxes); err != nil {
+		<-done
 		imapw.worker.PostMessage(&types.Error{
 			Message: types.RespondTo(msg),
 			Error:   err,