From 453636dfe2bbf177c74617862eb763485d4774bf Mon Sep 17 00:00:00 2001 From: Fabian Fritzsche Date: Tue, 7 Jul 2020 16:47:11 +0200 Subject: [PATCH] fix: add preview bypass for .gif files (#1012) --- http/preview.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/http/preview.go b/http/preview.go index 060d60eb..c219dbb2 100644 --- a/http/preview.go +++ b/http/preview.go @@ -59,6 +59,19 @@ func handleImagePreview(w http.ResponseWriter, r *http.Request, file *files.File return errToStatus(err), err } + fd, err := file.Fs.Open(file.Path) + if err != nil { + return errToStatus(err), err + } + defer fd.Close() + + if format == imaging.GIF && size == sizeBig { + if _, err := rawFileHandler(w, r, file); err != nil { //nolint: govet + return errToStatus(err), err + } + return 0, nil + } + var imgProcessor imageProcessor switch size { case sizeBig: @@ -73,12 +86,6 @@ func handleImagePreview(w http.ResponseWriter, r *http.Request, file *files.File return http.StatusBadRequest, fmt.Errorf("unsupported preview size %s", size) } - fd, err := file.Fs.Open(file.Path) - if err != nil { - return errToStatus(err), err - } - defer fd.Close() - img, err := imaging.Decode(fd, imaging.AutoOrientation(true)) if err != nil { return errToStatus(err), err