FileHasContents returns true iff f refers to a "file" or "bytes" schema blob, the server is configured with a "download helper", and the server responds that all chunks of 'f' are available and match the digest of wholeRef.
(ctx context.Context, f, wholeRef blob.Ref)
| 911 | // the server is configured with a "download helper", and the server responds |
| 912 | // that all chunks of 'f' are available and match the digest of wholeRef. |
| 913 | func (c *Client) FileHasContents(ctx context.Context, f, wholeRef blob.Ref) bool { |
| 914 | if err := c.condDiscovery(); err != nil { |
| 915 | return false |
| 916 | } |
| 917 | if c.downloadHelper == "" { |
| 918 | return false |
| 919 | } |
| 920 | req := c.newRequest(ctx, "HEAD", c.downloadHelper+f.String()+"/?verifycontents="+wholeRef.String()) |
| 921 | res, err := c.expect2XX(req) |
| 922 | if err != nil { |
| 923 | log.Printf("download helper HEAD error: %v", err) |
| 924 | return false |
| 925 | } |
| 926 | defer res.Body.Close() |
| 927 | return res.Header.Get("X-Camli-Contents") == wholeRef.String() |
| 928 | } |
| 929 | |
| 930 | // prefix returns the URL prefix before "/camli/", or before |
| 931 | // the blobref hash in case of a share URL. |
no test coverage detected