mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
check the original image for existence before os.Stat
Signed-off-by: Cocoa <0xbbc@0xbbc.com>
This commit is contained in:
parent
2b40d844a4
commit
735b7d2cda
@ -100,6 +100,14 @@ func main() {
|
||||
// /path/to
|
||||
DirPath := path.Dir(ImgPath)
|
||||
|
||||
// Check the original image for existence
|
||||
OriginalImgExists := imageExists(ImgAbsolutePath)
|
||||
if !OriginalImgExists {
|
||||
c.Send("File not found!")
|
||||
c.SendStatus(404)
|
||||
return
|
||||
}
|
||||
|
||||
// 1582558990
|
||||
STAT, err := os.Stat(ImgAbsolutePath)
|
||||
if err != nil {
|
||||
@ -131,7 +139,7 @@ func main() {
|
||||
}
|
||||
|
||||
// Check the original image for existence
|
||||
if !imageExists(ImgAbsolutePath) {
|
||||
if !OriginalImgExists {
|
||||
// The original image doesn't exist, check the webp image, delete if processed.
|
||||
if imageExists(WebpAbsolutePath) {
|
||||
os.Remove(WebpAbsolutePath)
|
||||
|
Loading…
x
Reference in New Issue
Block a user