diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-03-18 16:21:15 +0000 |
---|---|---|
committer | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-03-18 16:21:15 +0000 |
commit | e47dfe47865b3d4f3a086325d01f5c8d69f2b23f (patch) | |
tree | 16a3080545e50ccfbb40a12108cdf7b746dba196 /mediaapi/routing/download.go | |
parent | c54d88aecf78c717bfe83a2ed7295c74bfad9d90 (diff) |
Fix panic that can occur from nil pointer exception in media API `fetchRemoteFile`
Diffstat (limited to 'mediaapi/routing/download.go')
-rw-r--r-- | mediaapi/routing/download.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/mediaapi/routing/download.go b/mediaapi/routing/download.go index 95eab512..5f22a946 100644 --- a/mediaapi/routing/download.go +++ b/mediaapi/routing/download.go @@ -722,8 +722,8 @@ func (r *downloadRequest) fetchRemoteFile( // create request for remote file resp, err := client.CreateMediaDownloadRequest(ctx, r.MediaMetadata.Origin, string(r.MediaMetadata.MediaID)) - if err != nil || resp.StatusCode != http.StatusOK { - if resp.StatusCode == http.StatusNotFound { + if err != nil || (resp != nil && resp.StatusCode != http.StatusOK) { + if resp != nil && resp.StatusCode == http.StatusNotFound { return "", false, fmt.Errorf("File with media ID %q does not exist on %s", r.MediaMetadata.MediaID, r.MediaMetadata.Origin) } return "", false, fmt.Errorf("file with media ID %q could not be downloaded from %s", r.MediaMetadata.MediaID, r.MediaMetadata.Origin) |