maildir,notmuch: pass in-memory message to callback

This fixes piped full message (:pipe -m) being empty.

Fixes: 904ffacb0e ("maildir,notmuch: avoid leaking open files")
Signed-off-by: Nguyễn Gia Phong <mcsinyx@disroot.org>
This commit is contained in:
Nguyễn Gia Phong 2022-01-20 21:40:34 +07:00 committed by Robin Jarry
parent b96326517d
commit bf4abd309e
2 changed files with 14 additions and 2 deletions

View File

@ -1,9 +1,11 @@
package maildir
import (
"bytes"
"errors"
"fmt"
"io"
"io/ioutil"
"net/url"
"os"
"path/filepath"
@ -433,11 +435,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.worker.PostMessage(&types.FullMessage{
Message: types.RespondTo(msg),
Content: &models.FullMessage{
Uid: uid,
Reader: r,
Reader: bytes.NewReader(b),
},
}, nil)
}

View File

@ -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)
}