From e22918bb4407686610ca08c6ff69edef94600830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Lo=CC=88ffel?= Date: Wed, 6 Apr 2022 17:43:25 +0200 Subject: [PATCH] handle file name too long err --- main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.go b/main.go index 0693097..6ee6e21 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( "io/ioutil" "log" "os" + "syscall" "time" ) @@ -142,6 +143,12 @@ func main() { } if err = ioutil.WriteFile(fmt.Sprintf("%s/%s", dir, attachment.Filename), attachment.Body, 0644); err != nil { + if pe, ok := err.(*os.PathError); ok { + if pe.Err == syscall.ENAMETOOLONG { + log.Println(err.Error()) + continue + } + } log.Fatal(err) } }