working commit
This commit is contained in:
15
blobexist.go
15
blobexist.go
@@ -7,17 +7,16 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func (cli *Client) BlobExists(ctx context.Context, rawref string) (bool, int64, error) {
|
||||
func (cli *Client) BlobExists(ctx context.Context, rawrepo string, digest string) (bool, int64, error) {
|
||||
var err error
|
||||
var exist bool
|
||||
var size int64
|
||||
|
||||
ref, err := NewReference(rawref)
|
||||
ref, err := NewRepository(rawrepo)
|
||||
if err != nil {
|
||||
return exist, size, err
|
||||
}
|
||||
uri := ref.Blob()
|
||||
user, pass := ref.Userinfo()
|
||||
uri := ref.Blob(digest)
|
||||
|
||||
fmt.Println(uri)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodHead, uri, nil)
|
||||
@@ -27,14 +26,6 @@ func (cli *Client) BlobExists(ctx context.Context, rawref string) (bool, int64,
|
||||
req.Header.Set("User-Agent", cli.userAgent)
|
||||
req.Header.Set("Accept", "*/*")
|
||||
|
||||
if cli.authenticator != nil {
|
||||
authHeader, authKey, err := cli.authenticator.MakeHeader(user, pass)
|
||||
if err != nil {
|
||||
return exist, size, err
|
||||
}
|
||||
req.Header.Set(authHeader, authKey)
|
||||
}
|
||||
|
||||
resp, err := cli.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return exist, size, err
|
||||
|
||||
Reference in New Issue
Block a user