fix: add preview bypass for .gif files (#1012)

pull/1020/head
Fabian Fritzsche 2020-07-07 16:47:11 +02:00 committed by GitHub
parent b1605aa6d3
commit 453636dfe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 6 deletions

View File

@ -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