From 880ef32606b629b6f995a7f49a991edd3b0d3505 Mon Sep 17 00:00:00 2001 From: Benny~ Date: Sat, 7 Mar 2020 13:33:33 +0800 Subject: [PATCH] log update --- helper.go | 1 + router.go | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/helper.go b/helper.go index e8bbed1..6ede512 100644 --- a/helper.go +++ b/helper.go @@ -39,6 +39,7 @@ func ImageExists(filename string) bool { if os.IsNotExist(err) { return false } + log.Debugf("file %s exists!", filename) return !info.IsDir() } diff --git a/router.go b/router.go index c851d2e..5c3f4c6 100644 --- a/router.go +++ b/router.go @@ -42,8 +42,12 @@ func Convert(ImgPath string, ExhaustPath string, AllowedTypes []string, QUALITY } } if !allowed { - log.Warnf("File extension not allowed! %s", ImgFilename) - c.SendFile(RawImageAbs) + msg := "File extension not allowed! " + ImgFilename + log.Warn(msg) + c.Send(msg) + if ImageExists(RawImageAbs) { + c.SendFile(RawImageAbs) + } return } @@ -81,7 +85,7 @@ func Convert(ImgPath string, ExhaustPath string, AllowedTypes []string, QUALITY //for webp, we need to create dir first _ = os.MkdirAll(path.Dir(WebpAbsPath), 0755) q, _ := strconv.ParseFloat(QUALITY, 32) - err = WebpEncoder(RawImageAbs, WebpAbsPath, float32(q), verboseMode, nil) + err = WebpEncoder(RawImageAbs, WebpAbsPath, float32(q), true, nil) if err != nil { log.Error(err)