Skip to content

Commit

Permalink
handle file name too long err
Browse files Browse the repository at this point in the history
  • Loading branch information
loeffel-io committed Apr 6, 2022
1 parent 015ffe1 commit e22918b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io/ioutil"
"log"
"os"
"syscall"
"time"
)

Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit e22918b

Please sign in to comment.