From 143289bbd0736d72553a3c2a080aa3d125366b38 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 31 Mar 2019 11:29:57 -0400 Subject: Don't parse mail in worker; send a reader instead --- lib/msgstore.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/msgstore.go b/lib/msgstore.go index c6cd2c3..64b1638 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -1,10 +1,10 @@ package lib import ( + "io" "time" "github.com/emersion/go-imap" - "github.com/mohamedattahri/mail" "git.sr.ht/~sircmpwn/aerc2/worker/types" ) @@ -16,7 +16,7 @@ type MessageStore struct { // Ordered list of known UIDs Uids []uint32 - bodyCallbacks map[uint32][]func(*mail.Message) + bodyCallbacks map[uint32][]func(io.Reader) headerCallbacks map[uint32][]func(*types.MessageInfo) // Map of uids we've asked the worker to fetch @@ -33,7 +33,7 @@ func NewMessageStore(worker *types.Worker, Deleted: make(map[uint32]interface{}), DirInfo: *dirInfo, - bodyCallbacks: make(map[uint32][]func(*mail.Message)), + bodyCallbacks: make(map[uint32][]func(io.Reader)), headerCallbacks: make(map[uint32][]func(*types.MessageInfo)), pendingBodies: make(map[uint32]interface{}), @@ -66,8 +66,7 @@ func (store *MessageStore) FetchHeaders(uids []uint32, } } -func (store *MessageStore) FetchBodies(uids []uint32, - cb func(*mail.Message)) { +func (store *MessageStore) FetchBodies(uids []uint32, cb func(io.Reader)) { // TODO: this could be optimized by pre-allocating toFetch and trimming it // at the end. In practice we expect to get most messages back in one frame. @@ -80,7 +79,7 @@ func (store *MessageStore) FetchBodies(uids []uint32, if list, ok := store.bodyCallbacks[uid]; ok { store.bodyCallbacks[uid] = append(list, cb) } else { - store.bodyCallbacks[uid] = []func(*mail.Message){cb} + store.bodyCallbacks[uid] = []func(io.Reader){cb} } } } @@ -149,7 +148,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) { delete(store.pendingBodies, msg.Uid) if cbs, ok := store.bodyCallbacks[msg.Uid]; ok { for _, cb := range cbs { - cb(msg.Mail) + cb(msg.Reader) } } } -- cgit v1.2.3