aboutsummaryrefslogtreecommitdiffstats
path: root/worker/maildir/message.go
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2022-01-20 01:10:08 +0700
committerRobin Jarry <robin@jarry.cc>2022-01-19 20:18:00 +0100
commit904ffacb0e521218ba1f41e2e5c26d9ac41c9969 (patch)
tree4bb0dbe000b1241586f7fb0635ee076f70c22fe2 /worker/maildir/message.go
parentbeae17a6da37402d1c69dc76b476f55cbae982b8 (diff)
downloadaerc-904ffacb0e521218ba1f41e2e5c26d9ac41c9969.tar.gz
maildir,notmuch: avoid leaking open files
Previously, Message.NewReader returned the wrapped buffered reader without a reference to the opened file, so the files descriptors were left unclosed after reading. Now, the file reader is returned directly and closed on the call site. Buffering is not needed here because it is an implementation detail of go-message. Fixes: https://todo.sr.ht/~rjarry/aerc/9
Diffstat (limited to 'worker/maildir/message.go')
-rw-r--r--worker/maildir/message.go9
1 files changed, 2 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.