upload/oci: fix a crash when the uploader returns an empty response
resp.IsResumable crashes if resp.MultipartUploadResponse == nil. This happens for instance when authentication fails. Fix this by also checking the MultipartUploadResponse field. Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
parent
d6eacad494
commit
23718dc707
1 changed files with 3 additions and 1 deletions
|
|
@ -77,7 +77,9 @@ func (c Client) uploadToBucket(objectName string, bucketName string, namespace s
|
|||
ctx := context.Background()
|
||||
resp, err := uploadManager.UploadFile(ctx, req)
|
||||
if err != nil {
|
||||
if resp.IsResumable() {
|
||||
// resp.IsResumable crashes if resp.MultipartUploadResponse == nil
|
||||
// Thus, we need to check for both.
|
||||
if resp.MultipartUploadResponse != nil && resp.IsResumable() {
|
||||
resp, err = uploadManager.ResumeUploadFile(ctx, *resp.MultipartUploadResponse.UploadID)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue