Skip to content

Commit

Permalink
Fixed errcheck issues in server/channels/app/imaging/decode.go (matte…
Browse files Browse the repository at this point in the history
  • Loading branch information
Aryakoste authored Nov 8, 2024
1 parent 118d034 commit ead2a7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion server/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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|\
Expand Down
10 changes: 7 additions & 3 deletions server/channels/app/imaging/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ead2a7c

Please sign in to comment.