log update

This commit is contained in:
Benny~ 2020-03-07 13:33:33 +08:00
parent e2e39e0690
commit 880ef32606
No known key found for this signature in database
GPG Key ID: 6CD0DBDA5235D481
2 changed files with 8 additions and 3 deletions

View File

@ -39,6 +39,7 @@ func ImageExists(filename string) bool {
if os.IsNotExist(err) { if os.IsNotExist(err) {
return false return false
} }
log.Debugf("file %s exists!", filename)
return !info.IsDir() return !info.IsDir()
} }

View File

@ -42,8 +42,12 @@ func Convert(ImgPath string, ExhaustPath string, AllowedTypes []string, QUALITY
} }
} }
if !allowed { if !allowed {
log.Warnf("File extension not allowed! %s", ImgFilename) msg := "File extension not allowed! " + ImgFilename
log.Warn(msg)
c.Send(msg)
if ImageExists(RawImageAbs) {
c.SendFile(RawImageAbs) c.SendFile(RawImageAbs)
}
return return
} }
@ -81,7 +85,7 @@ func Convert(ImgPath string, ExhaustPath string, AllowedTypes []string, QUALITY
//for webp, we need to create dir first //for webp, we need to create dir first
_ = os.MkdirAll(path.Dir(WebpAbsPath), 0755) _ = os.MkdirAll(path.Dir(WebpAbsPath), 0755)
q, _ := strconv.ParseFloat(QUALITY, 32) q, _ := strconv.ParseFloat(QUALITY, 32)
err = WebpEncoder(RawImageAbs, WebpAbsPath, float32(q), verboseMode, nil) err = WebpEncoder(RawImageAbs, WebpAbsPath, float32(q), true, nil)
if err != nil { if err != nil {
log.Error(err) log.Error(err)