Authentication-Results: mail-b.sr.ht; dkim=pass header.d=disroot.org header.i=@disroot.org Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) by mail-b.sr.ht (Postfix) with ESMTPS id B92EE11EF86 for <~rjarry/aerc-devel@lists.sr.ht>; Thu, 20 Jan 2022 13:38:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 4F5F28E40; Thu, 20 Jan 2022 14:38:01 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with UTF8SMTP id 7dVbmgnUR65z; Thu, 20 Jan 2022 14:38:00 +0100 (CET) From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1642685879; bh=7252TrBepc6YnVm+a/HYwWfj/8zOFaGhrbXSOUTGsZg=; h=From:To:Cc:Subject:Date; b=i2McO7Q6MexFU2/Z7QYeVbq9LsRQGcIlY2gQcnhuvOiTHhic5/yGNIcbWZCGxqlFe gdBPUhhS7HLzLK6muRpMsz+lyPdNlzZ7FOBBnVaHFHOK+oE6QLs/QyAuEgXG7QtQcg tvHXOXZLg1yuyWSJC1IbuPU3t85/CC6PQhSTEjB+5a3ZxmP4vTgljTivXznTK+bCLM d9ExVy4gvHcZyAVnqWgnvIEcKoq3qyqeW4QZRgxtPDslzURkR/FyDErcx/ITsqOscU 61AAfEHAVkN6GFGOB96Frig1JKDOcogbDS678H1cb6HrmXBjdm65v2ouMNnyWoANvP cQOZ57pWMJlig== To: ~rjarry/aerc-devel@lists.sr.ht Cc: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Subject: [PATCH aerc v2] maildir: pass in-memory message to callback Date: Thu, 20 Jan 2022 20:36:30 +0700 Message-Id: <20220120133629.311485-1-mcsinyx@disroot.org> 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 --- BTW thank you Robin Jarry for the pointer to the recommendation for Linux change log, TIL. worker/maildir/worker.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go index a671d730fc25..2f75f12ae5e0 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) } -- 2.34.1