aboutsummaryrefslogtreecommitdiffstats
path: root/worker/lib/parse.go
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/lib/parse.go
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/lib/parse.go')
-rw-r--r--worker/lib/parse.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/worker/lib/parse.go b/worker/lib/parse.go
index 3baaa459..ac86292f 100644
--- a/worker/lib/parse.go
+++ b/worker/lib/parse.go
@@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"io"
+ "os"
"regexp"
"strings"
"time"
@@ -381,3 +382,12 @@ func ReadMessage(r io.Reader) (*message.Entity, error) {
}
return entity, nil
}
+
+// FileSize returns the size of the file specified by name
+func FileSize(name string) (uint32, error) {
+ fileInfo, err := os.Stat(name)
+ if err != nil {
+ return 0, fmt.Errorf("failed to obtain fileinfo: %w", err)
+ }
+ return uint32(fileInfo.Size()), nil
+}