Rename FetchMessageBodies to FetchFullMessages

This commit is contained in:
Drew DeVault 2019-03-31 12:17:57 -04:00
parent 27b25174e2
commit 95875b13f8
5 changed files with 17 additions and 17 deletions

View File

@ -22,7 +22,7 @@ func Pipe(aerc *widgets.Aerc, args []string) error {
acct := aerc.SelectedAccount() acct := aerc.SelectedAccount()
store := acct.Messages().Store() store := acct.Messages().Store()
msg := acct.Messages().Selected() msg := acct.Messages().Selected()
store.FetchBodies([]uint32{msg.Uid}, func(reader io.Reader) { store.FetchFull([]uint32{msg.Uid}, func(reader io.Reader) {
cmd := exec.Command(args[1], args[2:]...) cmd := exec.Command(args[1], args[2:]...)
pipe, err := cmd.StdinPipe() pipe, err := cmd.StdinPipe()
if err != nil { if err != nil {

View File

@ -66,7 +66,7 @@ func (store *MessageStore) FetchHeaders(uids []uint32,
} }
} }
func (store *MessageStore) FetchBodies(uids []uint32, cb func(io.Reader)) { func (store *MessageStore) FetchFull(uids []uint32, cb func(io.Reader)) {
// TODO: this could be optimized by pre-allocating toFetch and trimming it // 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. // at the end. In practice we expect to get most messages back in one frame.
var toFetch imap.SeqSet var toFetch imap.SeqSet
@ -84,7 +84,7 @@ func (store *MessageStore) FetchBodies(uids []uint32, cb func(io.Reader)) {
} }
} }
if !toFetch.Empty() { if !toFetch.Empty() {
store.worker.PostAction(&types.FetchMessageBodies{Uids: toFetch}, nil) store.worker.PostAction(&types.FetchFullMessages{Uids: toFetch}, nil)
} }
} }

View File

@ -21,15 +21,6 @@ func (imapw *IMAPWorker) handleFetchMessageHeaders(
imapw.handleFetchMessages(msg, &msg.Uids, items) imapw.handleFetchMessages(msg, &msg.Uids, items)
} }
func (imapw *IMAPWorker) handleFetchMessageBodies(
msg *types.FetchMessageBodies) {
imapw.worker.Logger.Printf("Fetching message bodies")
section := &imap.BodySectionName{}
items := []imap.FetchItem{section.FetchItem()}
imapw.handleFetchMessages(msg, &msg.Uids, items)
}
func (imapw *IMAPWorker) handleFetchMessageBodyPart( func (imapw *IMAPWorker) handleFetchMessageBodyPart(
msg *types.FetchMessageBodyPart) { msg *types.FetchMessageBodyPart) {
@ -42,6 +33,15 @@ func (imapw *IMAPWorker) handleFetchMessageBodyPart(
imapw.handleFetchMessages(msg, &uids, items) imapw.handleFetchMessages(msg, &uids, items)
} }
func (imapw *IMAPWorker) handleFetchFullMessages(
msg *types.FetchFullMessages) {
imapw.worker.Logger.Printf("Fetching full messages")
section := &imap.BodySectionName{}
items := []imap.FetchItem{section.FetchItem()}
imapw.handleFetchMessages(msg, &msg.Uids, items)
}
func (imapw *IMAPWorker) handleFetchMessages( func (imapw *IMAPWorker) handleFetchMessages(
msg types.WorkerMessage, uids *imap.SeqSet, items []imap.FetchItem) { msg types.WorkerMessage, uids *imap.SeqSet, items []imap.FetchItem) {
@ -64,7 +64,7 @@ func (imapw *IMAPWorker) handleFetchMessages(
InternalDate: _msg.InternalDate, InternalDate: _msg.InternalDate,
Uid: _msg.Uid, Uid: _msg.Uid,
}, nil) }, nil)
case *types.FetchMessageBodies: case *types.FetchFullMessages:
reader := _msg.GetBody(section) reader := _msg.GetBody(section)
imapw.worker.PostMessage(&types.MessageBody{ imapw.worker.PostMessage(&types.MessageBody{
Reader: reader, Reader: reader,

View File

@ -158,10 +158,10 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error {
w.handleFetchDirectoryContents(msg) w.handleFetchDirectoryContents(msg)
case *types.FetchMessageHeaders: case *types.FetchMessageHeaders:
w.handleFetchMessageHeaders(msg) w.handleFetchMessageHeaders(msg)
case *types.FetchMessageBodies:
w.handleFetchMessageBodies(msg)
case *types.FetchMessageBodyPart: case *types.FetchMessageBodyPart:
w.handleFetchMessageBodyPart(msg) w.handleFetchMessageBodyPart(msg)
case *types.FetchFullMessages:
w.handleFetchFullMessages(msg)
case *types.DeleteMessages: case *types.DeleteMessages:
w.handleDeleteMessages(msg) w.handleDeleteMessages(msg)
default: default:

View File

@ -81,7 +81,7 @@ type FetchMessageHeaders struct {
Uids imap.SeqSet Uids imap.SeqSet
} }
type FetchMessageBodies struct { type FetchFullMessages struct {
Message Message
Uids imap.SeqSet Uids imap.SeqSet
} }
@ -134,7 +134,7 @@ type MessageInfo struct {
Uid uint32 Uid uint32
} }
type MessageBody struct { type FullMessage struct {
Message Message
Reader io.Reader Reader io.Reader
Uid uint32 Uid uint32