diff --git a/registry/client/repository.go b/registry/client/repository.go index 10c6fe3f0..4a5d452d1 100644 --- a/registry/client/repository.go +++ b/registry/client/repository.go @@ -519,21 +519,23 @@ func (ms *manifests) Get(ctx context.Context, dgst digest.Digest, options ...dis if resp.StatusCode == http.StatusNotModified { return nil, distribution.ErrManifestNotModified } else if SuccessStatus(resp.StatusCode) { - if contentDgst != nil { - dgst, err := digest.Parse(resp.Header.Get("Docker-Content-Digest")) - if err == nil { - *contentDgst = dgst - } - } mt := resp.Header.Get("Content-Type") body, err := io.ReadAll(resp.Body) if err != nil { return nil, err } - m, _, err := distribution.UnmarshalManifest(mt, body) + m, desc, err := distribution.UnmarshalManifest(mt, body) if err != nil { return nil, err } + if contentDgst != nil { + dgst, err := digest.Parse(resp.Header.Get("Docker-Content-Digest")) + if err == nil { + *contentDgst = dgst + } else { + *contentDgst = desc.Digest + } + } return m, nil } return nil, HandleErrorResponse(resp)