Wait for listing to complete before sending Done
This commit is contained in:
parent
e85ef71935
commit
3a5b4c229e
1 changed files with 3 additions and 0 deletions
|
@ -9,6 +9,7 @@ import (
|
||||||
func (imapw *IMAPWorker) handleListDirectories(msg *types.ListDirectories) {
|
func (imapw *IMAPWorker) handleListDirectories(msg *types.ListDirectories) {
|
||||||
mailboxes := make(chan *imap.MailboxInfo)
|
mailboxes := make(chan *imap.MailboxInfo)
|
||||||
imapw.worker.Logger.Println("Listing mailboxes")
|
imapw.worker.Logger.Println("Listing mailboxes")
|
||||||
|
done := make(chan interface{})
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for mbox := range mailboxes {
|
for mbox := range mailboxes {
|
||||||
|
@ -22,9 +23,11 @@ func (imapw *IMAPWorker) handleListDirectories(msg *types.ListDirectories) {
|
||||||
Attributes: mbox.Attributes,
|
Attributes: mbox.Attributes,
|
||||||
}, nil)
|
}, nil)
|
||||||
}
|
}
|
||||||
|
done <- nil
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err := imapw.client.List("", "*", mailboxes); err != nil {
|
if err := imapw.client.List("", "*", mailboxes); err != nil {
|
||||||
|
<-done
|
||||||
imapw.worker.PostMessage(&types.Error{
|
imapw.worker.PostMessage(&types.Error{
|
||||||
Message: types.RespondTo(msg),
|
Message: types.RespondTo(msg),
|
||||||
Error: err,
|
Error: err,
|
||||||
|
|
Loading…
Reference in a new issue