@@ -392,27 +392,27 @@ func (ref ociReference) getBlob(d digest.Digest, sharedBlobDir string) (io.ReadC
392392 return r , fi .Size (), nil
393393}
394394
395- func (ref ociReference ) getOCIDescriptorContents (desc imgspecv1. Descriptor , maxSize int , sharedBlobDir string ) ([]byte , error ) {
396- if err := desc . Digest .Validate (); err != nil { // .Algorithm() might panic without this check
397- return nil , fmt .Errorf ("invalid digest %q: %w" , desc . Digest .String (), err )
395+ func (ref ociReference ) getOCIDescriptorContents (dgst digest. Digest , maxSize int , sharedBlobDir string ) ([]byte , error ) {
396+ if err := dgst .Validate (); err != nil { // .Algorithm() might panic without this check
397+ return nil , fmt .Errorf ("invalid digest %q: %w" , dgst .String (), err )
398398 }
399- digestAlgorithm := desc . Digest .Algorithm ()
399+ digestAlgorithm := dgst .Algorithm ()
400400 if ! digestAlgorithm .Available () {
401- return nil , fmt .Errorf ("invalid digest %q: unsupported digest algorithm %q" , desc . Digest .String (), digestAlgorithm .String ())
401+ return nil , fmt .Errorf ("invalid digest %q: unsupported digest algorithm %q" , dgst .String (), digestAlgorithm .String ())
402402 }
403403
404- reader , _ , err := ref .getBlob (desc . Digest , sharedBlobDir )
404+ reader , _ , err := ref .getBlob (dgst , sharedBlobDir )
405405 if err != nil {
406406 return nil , err
407407 }
408408 defer reader .Close ()
409409 payload , err := iolimits .ReadAtMost (reader , maxSize )
410410 if err != nil {
411- return nil , fmt .Errorf ("reading blob %s in %s: %w" , desc . Digest .String (), ref .image , err )
411+ return nil , fmt .Errorf ("reading blob %s in %s: %w" , dgst .String (), ref .image , err )
412412 }
413413 actualDigest := digestAlgorithm .FromBytes (payload )
414- if actualDigest != desc . Digest {
415- return nil , fmt .Errorf ("digest mismatch, expected %q, got %q" , desc . Digest .String (), actualDigest .String ())
414+ if actualDigest != dgst {
415+ return nil , fmt .Errorf ("digest mismatch, expected %q, got %q" , dgst .String (), actualDigest .String ())
416416 }
417417 return payload , nil
418418}
0 commit comments