oci/layout/oci_dest.go
func (d *ociImageDestination) TryReusingBlob(ctx context.Context, info types.BlobInfo, cache types.BlobInfoCache, canSubstitute bool) (bool, types.BlobInfo, error) {
	if info.Digest == "" {
		return false, types.BlobInfo{}, errors.Errorf(`"Can not check for a blob with unknown digest`)
	}
	blobPath, err := d.ref.blobPath(info.Digest, d.sharedBlobDir)
	if err != nil {
		return false, types.BlobInfo{}, err
	}
	finfo, err := os.Stat(blobPath)
	if err != nil && os.IsNotExist(err) {
		return false, types.BlobInfo{}, nil
	}
	if err != nil {
		return false, types.BlobInfo{}, err
	}
	return true, types.BlobInfo{Digest: info.Digest, Size: finfo.Size()}, nil
}
func (d *ociImageDestination) TryReusingBlob(ctx context.Context, info types.BlobInfo, cache types.BlobInfoCache, canSubstitute bool) (bool, types.BlobInfo, error) {
	if info.Digest == "" {
		return false, types.BlobInfo{}, errors.Errorf(`"Can not check for a blob with unknown digest`)
	}
	blobPath, err := d.ref.blobPath(info.Digest, d.sharedBlobDir)
	if err != nil {
		return false, types.BlobInfo{}, err
	}
	finfo, err := os.Stat(blobPath)
	if err != nil && os.IsNotExist(err) {
		return false, types.BlobInfo{}, nil
	}
	if err != nil {
		return false, types.BlobInfo{}, err
	}
	return true, types.BlobInfo{Digest: info.Digest, Size: finfo.Size()}, nil
}
func ( d * ociImageDestination ) TryReusingBlob ( ctx context . Context , info types . BlobInfo , cache types . BlobInfoCache , canSubstitute bool ) ( bool , types . BlobInfo , error ) { if info . Digest == " " { return false , types . BlobInfo { } , errors . Errorf ( `"Can not check for a blob with unknown digest` ) } blobPath , err := d . ref . blobPath ( info . Digest , d . sharedBlobDir ) if err != nil { return false , types . BlobInfo { } , err } finfo , err := os . Stat ( blobPath ) if err != nil && os . IsNotExist ( err ) { return false , types . BlobInfo { } , nil } if err != nil { return false , types . BlobInfo { } , err } return true , types . BlobInfo { Digest : info . Digest , Size : finfo . Size ( ) } , nil }
// TryReusingBlob checks whether the transport already contains, or can efficiently reuse, a blob, and if so, applies it to the current destination
// (e.g. if the blob is a filesystem layer, this signifies that the changes it describes need to be applied again when composing a filesystem tree).
// info.Digest must not be empty.
// If canSubstitute, TryReusingBlob can use an equivalent equivalent of the desired blob; in that case the returned info may not match the input.
// If the blob has been succesfully reused, returns (true, info, nil); info must contain at least a digest and size.
// If the transport can not reuse the requested blob, TryReusingBlob returns (false, {}, nil); it returns a non-nil error only on an unexpected failure.
// May use and/or update cache.
TryReusingBlob checks whether the transport already contains or can efficiently reuse a blob and if so applies it to the current destination ( e . g . if the blob is a filesystem layer this signifies that the changes it describes need to be applied again when composing a filesystem tree ) . info . Digest must not be empty . If canSubstitute TryReusingBlob can use an equivalent equivalent of the desired blob ; in that case the returned info may not match the input . If the blob has been succesfully reused returns ( true info nil ) ; info must contain at least a digest and size . If the transport can not reuse the requested blob TryReusingBlob returns ( false {} nil ) ; it returns a non - nil error only on an unexpected failure . May use and / or update cache .