Tidy up list.go

This commit is contained in:
Drew DeVault 2018-02-02 08:44:30 -05:00
parent d603bbe2ce
commit 25f21b55bd

View file

@ -14,10 +14,14 @@ func (imapw *IMAPWorker) handleListDirectories(msg *types.ListDirectories) {
done <- imapw.client.List("", "*", mailboxes) done <- imapw.client.List("", "*", mailboxes)
}() }()
go func() { go func() {
for { for mbox := range mailboxes {
select { imapw.worker.PostMessage(&types.Directory{
case err := <-done: Message: types.RespondTo(msg),
if err != nil { Name: mbox.Name,
Attributes: mbox.Attributes,
}, nil)
}
if err := <-done; err != nil {
imapw.worker.PostMessage(&types.Error{ imapw.worker.PostMessage(&types.Error{
Message: types.RespondTo(msg), Message: types.RespondTo(msg),
Error: err, Error: err,
@ -26,16 +30,5 @@ func (imapw *IMAPWorker) handleListDirectories(msg *types.ListDirectories) {
imapw.worker.PostMessage( imapw.worker.PostMessage(
&types.Done{types.RespondTo(msg)}, nil) &types.Done{types.RespondTo(msg)}, nil)
} }
return
case mbox := <-mailboxes:
if mbox != nil {
imapw.worker.PostMessage(&types.Directory{
Message: types.RespondTo(msg),
Name: mbox.Name,
Attributes: mbox.Attributes,
}, nil)
}
}
}
}() }()
} }