From a811db410bf321f0820f4464f51f371ebb012db1 Mon Sep 17 00:00:00 2001 From: Adnan Hajdarevic Date: Thu, 21 Dec 2017 13:25:19 +0100 Subject: [PATCH] check before removing --- webhook.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/webhook.go b/webhook.go index 79c2c7ac..71fdc6bf 100644 --- a/webhook.go +++ b/webhook.go @@ -397,10 +397,12 @@ func handleHook(h *hook.Hook, rid string, headers, query, payload *map[string]in } for i := range files { - log.Printf("[%s] removing file %s\n", rid, files[i].File.Name()) - err := os.Remove(files[i].File.Name()) - if err != nil { - log.Printf("[%s] error removing file %s [%s]", rid, files[i].File.Name(), err) + if files[i].File != nil { + log.Printf("[%s] removing file %s\n", rid, files[i].File.Name()) + err := os.Remove(files[i].File.Name()) + if err != nil { + log.Printf("[%s] error removing file %s [%s]", rid, files[i].File.Name(), err) + } } }