aboutsummaryrefslogtreecommitdiffstats
path: root/worker/maildir
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2023-04-24 23:18:49 +0200
committerRobin Jarry <robin@jarry.cc>2023-04-26 00:07:43 +0200
commitf04d83e80af70f9d29a1c515e93238eeb356ad2d (patch)
treec77c65957f000601894cbc717bbcaa56cf411f7f /worker/maildir
parent8e39fbd80869d5c80ff339498e6b06341f9f00af (diff)
downloadaerc-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/maildir')
-rw-r--r--worker/maildir/message.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/worker/maildir/message.go b/worker/maildir/message.go
index a941624a..0b653fa6 100644
--- a/worker/maildir/message.go
+++ b/worker/maildir/message.go
@@ -6,6 +6,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"
)
@@ -73,7 +74,19 @@ func (m Message) Remove() 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.dir.Filename(m.key); 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
}
// MessageHeaders populates a models.MessageInfo struct for the message with