diff options
author | Robin Jarry <robin@jarry.cc> | 2023-10-17 14:40:08 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-10-28 19:24:55 +0200 |
commit | 57088312fdd8e602a084bd5736a0e22a34be9ec0 (patch) | |
tree | 8c5544262cf8c1772ec661748cfa4d5491ff4c77 /worker/lib/size.go | |
parent | 591659b52867cb118d1f82d41693a02123935e0c (diff) | |
download | aerc-57088312fdd8e602a084bd5736a0e22a34be9ec0.tar.gz |
worker: move shared code to lib
Avoid importing code from worker/lib into lib. It should only be the
other way around. Move the message parsing code used by maildir,
notmuch, mbox and the eml viewer into a lib/rfc822 package.
Adapt imports accordingly.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
Tested-by: Inwit <inwit@sindominio.net>
Diffstat (limited to 'worker/lib/size.go')
-rw-r--r-- | worker/lib/size.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/worker/lib/size.go b/worker/lib/size.go new file mode 100644 index 00000000..f00437c3 --- /dev/null +++ b/worker/lib/size.go @@ -0,0 +1,15 @@ +package lib + +import ( + "fmt" + "os" +) + +// 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 +} |