summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-06-02 13:26:43 -0400
committerDrew DeVault <sir@cmpwn.com>2019-06-02 13:26:43 -0400
commite85ef71935c145307b67cf6af2477d1c2d041075 (patch)
tree48553b5772f579f1a4fb03147b786ba9d1a5c90a
parenta81467dda9d577be706a1875451a3b031840639d (diff)
downloadaerc-e85ef71935c145307b67cf6af2477d1c2d041075.tar.gz
Don't send Done until finished fetching messages
-rw-r--r--worker/imap/fetch.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/worker/imap/fetch.go b/worker/imap/fetch.go
index c5e7cd6..ac9d009 100644
--- a/worker/imap/fetch.go
+++ b/worker/imap/fetch.go
@@ -47,6 +47,7 @@ func (imapw *IMAPWorker) handleFetchMessages(
 	section *imap.BodySectionName) {
 
 	messages := make(chan *imap.Message)
+	done := make(chan interface{})
 
 	go func() {
 		for _msg := range messages {
@@ -77,6 +78,7 @@ func (imapw *IMAPWorker) handleFetchMessages(
 				}, nil)
 			}
 		}
+		done <- nil
 	}()
 
 	if err := imapw.client.UidFetch(uids, items, messages); err != nil {
@@ -85,6 +87,7 @@ func (imapw *IMAPWorker) handleFetchMessages(
 			Error:   err,
 		}, nil)
 	} else {
+		<-done
 		imapw.worker.PostMessage(
 			&types.Done{types.RespondTo(msg)}, nil)
 	}