diff options
author | Koni Marti <koni.marti@gmail.com> | 2023-04-24 23:18:49 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-04-26 00:07:43 +0200 |
commit | f04d83e80af70f9d29a1c515e93238eeb356ad2d (patch) | |
tree | c77c65957f000601894cbc717bbcaa56cf411f7f /worker/notmuch/message.go | |
parent | 8e39fbd80869d5c80ff339498e6b06341f9f00af (diff) | |
download | aerc-f04d83e80af70f9d29a1c515e93238eeb356ad2d.tar.gz |
messageinfo: report message sizes
Report sizes of the message across all backends.
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/notmuch/message.go')
-rw-r--r-- | worker/notmuch/message.go | 15 |
1 files changed, 14 insertions, 1 deletions
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 |