From f04d83e80af70f9d29a1c515e93238eeb356ad2d Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Mon, 24 Apr 2023 23:18:49 +0200 Subject: messageinfo: report message sizes Report sizes of the message across all backends. Signed-off-by: Koni Marti Acked-by: Robin Jarry --- worker/notmuch/message.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'worker/notmuch') diff --git a/worker/notmuch/message.go b/worker/notmuch/message.go index 28731d3d..b6d7f54c 100644 --- a/worker/notmuch/message.go +++ b/worker/notmuch/message.go @@ -12,6 +12,7 @@ import ( "github.com/emersion/go-maildir" + "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" "git.sr.ht/~rjarry/aerc/worker/lib" notmuch "git.sr.ht/~rjarry/aerc/worker/notmuch/lib" @@ -34,7 +35,19 @@ func (m *Message) NewReader() (io.ReadCloser, error) { // MessageInfo populates a models.MessageInfo struct for the message. func (m *Message) MessageInfo() (*models.MessageInfo, error) { - return lib.MessageInfo(m) + info, err := lib.MessageInfo(m) + if err != nil { + return nil, err + } + // if size retrieval fails, just return info and log error + if name, err := m.Filename(); err != nil { + log.Errorf("failed to obtain filename: %v", err) + } else { + if info.Size, err = lib.FileSize(name); err != nil { + log.Errorf("failed to obtain file size: %v", err) + } + } + return info, nil } // NewBodyPartReader creates a new io.Reader for the requested body part(s) of -- cgit