aboutsummaryrefslogtreecommitdiffstats
path: root/worker/maildir
diff options
context:
space:
mode:
Diffstat (limited to 'worker/maildir')
-rw-r--r--worker/maildir/message.go9
-rw-r--r--worker/maildir/search.go1
-rw-r--r--worker/maildir/worker.go1
3 files changed, 4 insertions, 7 deletions
diff --git a/worker/maildir/message.go b/worker/maildir/message.go
index dbc9ade1..b73e0832 100644
--- a/worker/maildir/message.go
+++ b/worker/maildir/message.go
@@ -1,7 +1,6 @@
package maildir
import (
- "bufio"
"fmt"
"io"
@@ -20,12 +19,8 @@ type Message struct {
}
// NewReader reads a message into memory and returns an io.Reader for it.
-func (m Message) NewReader() (io.Reader, error) {
- f, err := m.dir.Open(m.key)
- if err != nil {
- return nil, err
- }
- return bufio.NewReader(f), nil
+func (m Message) NewReader() (io.ReadCloser, error) {
+ return m.dir.Open(m.key)
}
// Flags fetches the set of flags currently applied to the message.
diff --git a/worker/maildir/search.go b/worker/maildir/search.go
index edfb8d84..7f97fb1a 100644
--- a/worker/maildir/search.go
+++ b/worker/maildir/search.go
@@ -159,6 +159,7 @@ func (w *Worker) searchKey(key uint32, criteria *searchCriteria,
if err != nil {
return false, err
}
+ defer reader.Close()
bytes, err := ioutil.ReadAll(reader)
if err != nil {
return false, err
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go
index 621b19e3..a671d730 100644
--- a/worker/maildir/worker.go
+++ b/worker/maildir/worker.go
@@ -432,6 +432,7 @@ func (w *Worker) handleFetchFullMessages(msg *types.FetchFullMessages) error {
w.worker.Logger.Printf("could not get message reader: %v", err)
return err
}
+ defer r.Close()
w.worker.PostMessage(&types.FullMessage{
Message: types.RespondTo(msg),
Content: &models.FullMessage{