From bf4abd309e4c5c4eb3a43017ed20e4a3cf85fee1 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Thu, 20 Jan 2022 21:40:34 +0700 Subject: maildir,notmuch: pass in-memory message to callback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes piped full message (:pipe -m) being empty. Fixes: 904ffacb0e52 ("maildir,notmuch: avoid leaking open files") Signed-off-by: Nguyễn Gia Phong --- worker/notmuch/worker.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'worker/notmuch') diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go index d95d6ba3..36ed2c8f 100644 --- a/worker/notmuch/worker.go +++ b/worker/notmuch/worker.go @@ -5,7 +5,9 @@ package notmuch import ( "bufio" + "bytes" "fmt" + "io/ioutil" "net/url" "os" "path/filepath" @@ -368,11 +370,15 @@ func (w *worker) handleFetchFullMessages(msg *types.FetchFullMessages) error { return err } defer r.Close() + b, err := ioutil.ReadAll(r) + if err != nil { + return err + } w.w.PostMessage(&types.FullMessage{ Message: types.RespondTo(msg), Content: &models.FullMessage{ Uid: uid, - Reader: r, + Reader: bytes.NewReader(b), }, }, nil) } -- cgit