Skip to content

Commit e22918b

Browse files
committed
handle file name too long err
1 parent 015ffe1 commit e22918b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"io/ioutil"
1010
"log"
1111
"os"
12+
"syscall"
1213
"time"
1314
)
1415

@@ -142,6 +143,12 @@ func main() {
142143
}
143144

144145
if err = ioutil.WriteFile(fmt.Sprintf("%s/%s", dir, attachment.Filename), attachment.Body, 0644); err != nil {
146+
if pe, ok := err.(*os.PathError); ok {
147+
if pe.Err == syscall.ENAMETOOLONG {
148+
log.Println(err.Error())
149+
continue
150+
}
151+
}
145152
log.Fatal(err)
146153
}
147154
}

0 commit comments

Comments
 (0)