summaryrefslogtreecommitdiff
path: root/worker
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2022-01-20 21:40:34 +0700
committerRobin Jarry <robin@jarry.cc>2022-01-20 15:44:46 +0100
commitbf4abd309e4c5c4eb3a43017ed20e4a3cf85fee1 (patch)
tree9793bffa4aaef64731f7411b392abd4d5f92fcc7 /worker
parentb96326517d2f553838795b78d67210f50d0ecc63 (diff)
downloadaerc-bf4abd309e4c5c4eb3a43017ed20e4a3cf85fee1.zip
maildir,notmuch: pass in-memory message to callback
This fixes piped full message (:pipe -m) being empty. Fixes: 904ffacb0e52 ("maildir,notmuch: avoid leaking open files") Signed-off-by: Nguyễn Gia Phong <mcsinyx@disroot.org>
Diffstat (limited to 'worker')
-rw-r--r--worker/maildir/worker.go8
-rw-r--r--worker/notmuch/worker.go8
2 files changed, 14 insertions, 2 deletions
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go
index a671d73..2f75f12 100644
--- a/worker/maildir/worker.go
+++ b/worker/maildir/worker.go
@@ -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)
}
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go
index d95d6ba..36ed2c8 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)
}