Tidy up list.go

This commit is contained in:
Drew DeVault 2018-02-02 08:44:30 -05:00
parent d603bbe2ce
commit 25f21b55bd
1 changed files with 15 additions and 22 deletions

View File

@ -14,28 +14,21 @@ 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,
imapw.worker.PostMessage(&types.Error{ Attributes: mbox.Attributes,
Message: types.RespondTo(msg), }, nil)
Error: err, }
}, nil) if err := <-done; err != nil {
} else { imapw.worker.PostMessage(&types.Error{
imapw.worker.PostMessage( Message: types.RespondTo(msg),
&types.Done{types.RespondTo(msg)}, nil) Error: err,
} }, nil)
return } else {
case mbox := <-mailboxes: imapw.worker.PostMessage(
if mbox != nil { &types.Done{types.RespondTo(msg)}, nil)
imapw.worker.PostMessage(&types.Directory{
Message: types.RespondTo(msg),
Name: mbox.Name,
Attributes: mbox.Attributes,
}, nil)
}
}
} }
}() }()
} }