Skip to content

Commit

Permalink
fixes channel closing when no message are present
Browse files Browse the repository at this point in the history
  • Loading branch information
rwese committed Aug 14, 2021
1 parent 536c1df commit ddcb5b8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions archivar/archiver/archivers/imap/client/imap.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (i *Imap) GetMessages(messageChan chan *imap.Message, deleteDownloaded bool
}

func (i *Imap) processInboxMessages(inbox string, messageChan chan *imap.Message, deleteDownloaded bool) (err error) {
mbox, err := i.client.Select(inbox, false)
_, err = i.client.Select(inbox, false)
if err != nil {
i.ListInboxes()
return err
Expand All @@ -273,13 +273,14 @@ func (i *Imap) processInboxMessages(inbox string, messageChan chan *imap.Message

criteria := imap.NewSearchCriteria()
criteria.WithoutFlags = []string{imap.DeletedFlag}
criteria.WithoutFlags = append(criteria.WithoutFlags, imap.SeenFlag)

foundMsgs, err := i.client.Search(criteria)
if err != nil {
return err
}

if mbox.Messages == 0 {
if len(foundMsgs) == 0 {
i.logger.Debug("no messages")
return nil
}
Expand Down

0 comments on commit ddcb5b8

Please sign in to comment.