diff --git a/server/.golangci.yml b/server/.golangci.yml index 5ab81eee5c7..ff0ee3fd7c7 100644 --- a/server/.golangci.yml +++ b/server/.golangci.yml @@ -96,7 +96,6 @@ issues: channels/app/file_info.go|\ channels/app/file_test.go|\ channels/app/helper_test.go|\ - channels/app/imaging/decode.go|\ channels/app/import_functions.go|\ channels/app/import_functions_test.go|\ channels/app/imports/import_validators.go|\ diff --git a/server/channels/app/imaging/decode.go b/server/channels/app/imaging/decode.go index 215c4caf27b..756ee1f8eef 100644 --- a/server/channels/app/imaging/decode.go +++ b/server/channels/app/imaging/decode.go @@ -112,12 +112,16 @@ func (d *Decoder) DecodeConfig(rd io.Reader) (image.Config, string, error) { } // GetDimensions returns the dimensions for the given encoded image data. -func GetDimensions(imageData io.Reader) (int, int, error) { +func GetDimensions(imageData io.Reader) (width int, height int, err error) { cfg, _, err := image.DecodeConfig(imageData) + width, height = cfg.Width, cfg.Height if seeker, ok := imageData.(io.Seeker); ok { - defer seeker.Seek(0, 0) + _, err2 := seeker.Seek(0, 0) + if err == nil && err2 != nil { + err = fmt.Errorf("failed to seek back to the beginning of the image data: %w", err2) + } } - return cfg.Width, cfg.Height, err + return } // This is only needed to try and simplify GC work.