func (d *dockerImageDestination) blobExists(ctx context.Context, repo reference.Named, digest digest.Digest, extraScope *authScope) (bool, int64, error) {
	checkPath := fmt.Sprintf(blobsPath, reference.Path(repo), digest.String())
	logrus.Debugf("Checking %s", checkPath)
	res, err := d.c.makeRequest(ctx, "HEAD", checkPath, nil, nil, v2Auth, extraScope)
	if err != nil {
		return false, -1, err
	}
	defer res.Body.Close()
	switch res.StatusCode {
	case http.StatusOK:
		logrus.Debugf("... already exists")
		return true, getBlobSize(res), nil
	case http.StatusUnauthorized:
		logrus.Debugf("... not authorized")
		return false, -1, errors.Wrapf(client.HandleErrorResponse(res), "Error checking whether a blob %s exists in %s", digest, repo.Name())
	case http.StatusNotFound:
		logrus.Debugf("... not present")
		return false, -1, nil
	default:
		return false, -1, errors.Errorf("failed to read from destination repository %s: %d (%s)", reference.Path(d.ref.ref), res.StatusCode, http.StatusText(res.StatusCode))
	}
}
func (d *dockerImageDestination) blobExists(ctx context.Context, repo reference.Named, digest digest.Digest, extraScope *authScope) (bool, int64, error) {
	checkPath := fmt.Sprintf(blobsPath, reference.Path(repo), digest.String())
	logrus.Debugf("Checking %s", checkPath)
	res, err := d.c.makeRequest(ctx, "HEAD", checkPath, nil, nil, v2Auth, extraScope)
	if err != nil {
		return false, -1, err
	}
	defer res.Body.Close()
	switch res.StatusCode {
	case http.StatusOK:
		logrus.Debugf("... already exists")
		return true, getBlobSize(res), nil
	case http.StatusUnauthorized:
		logrus.Debugf("... not authorized")
		return false, -1, errors.Wrapf(client.HandleErrorResponse(res), "Error checking whether a blob %s exists in %s", digest, repo.Name())
	case http.StatusNotFound:
		logrus.Debugf("... not present")
		return false, -1, nil
	default:
		return false, -1, errors.Errorf("failed to read from destination repository %s: %d (%s)", reference.Path(d.ref.ref), res.StatusCode, http.StatusText(res.StatusCode))
	}
}
func ( d * dockerImageDestination ) blobExists ( ctx context . Context , repo reference . Named , digest digest . Digest , extraScope * authScope ) ( bool , int64 , error ) { checkPath := fmt . Sprintf ( blobsPath , reference . Path ( repo ) , digest . String ( ) ) logrus . Debugf ( " " , checkPath ) res , err := d . c . makeRequest ( ctx , " " , checkPath , nil , nil , v2Auth , extraScope ) if err != nil { return false , - 1 , err } defer res . Body . Close ( ) switch res . StatusCode { case http . StatusOK : logrus . Debugf ( " " ) return true , getBlobSize ( res ) , nil case http . StatusUnauthorized : logrus . Debugf ( " " ) return false , - 1 , errors . Wrapf ( client . HandleErrorResponse ( res ) , " " , digest , repo . Name ( ) ) case http . StatusNotFound : logrus . Debugf ( " " ) return false , - 1 , nil default : return false , - 1 , errors . Errorf ( " " , reference . Path ( d . ref . ref ) , res . StatusCode , http . StatusText ( res . StatusCode ) ) } }
// blobExists returns true iff repo contains a blob with digest, and if so, also its size.
// If the destination does not contain the blob, or it is unknown, blobExists ordinarily returns (false, -1, nil);
// it returns a non-nil error only on an unexpected failure.
blobExists returns true iff repo contains a blob with digest and if so also its size . If the destination does not contain the blob or it is unknown blobExists ordinarily returns ( false - 1 nil ) ; it returns a non - nil error only on an unexpected failure .