// StatBlobs stats multiple blobs and returns a map
// of the found refs to their sizes.
190704
func StatBlobs(ctx context.Context, bs BlobStatter, blobs []blob.Ref) (map[blob.Ref]blob.SizedRef, error) {
	var m map[blob.Ref]blob.SizedRef
	err := bs.StatBlobs(ctx, blobs, func(sb blob.SizedRef) error {
		if m == nil {
			m = make(map[blob.Ref]blob.SizedRef)
		}
		m[sb.Ref] = sb
		return nil
	})
	return m, err
}
7692
func ReadBlob(ctx context.Context, provider Provider, desc ocispec.Descriptor) ([]byte, error) {
	ra, err := provider.ReaderAt(ctx, desc)
	if err != nil {
		return nil, err
	}
	defer ra.Close()

	p := make([]byte, ra.Size())

	_, err = ra.ReadAt(p, 0)
	return p, err
}
7934
func (i *Index) ReferenceStats(id int) (stats index.ReferenceStats, ok bool) {
	s := i.refs[id].stats
	if s == nil {
		return index.ReferenceStats{}, false
	}
	return *s, true
}
1233687
func (s *Storage) BlobContents(br blob.Ref) (contents string, ok bool) {
	s.mu.RLock()
	defer s.mu.RUnlock()
	b, ok := s.m[br]
	if !ok {
		return
	}
	return string(b), true
}
1243893
func (db *CLevelDB) Stats() map[string]string {
	keys := []string{
		"leveldb.aliveiters",
		"leveldb.alivesnaps",
		"leveldb.blockpool",
		"leveldb.cachedblock",
		"leveldb.num-files-at-level{n}",
		"leveldb.openedtables",
		"leveldb.sstables",
		"leveldb.stats",
	}

	stats := make(map[string]string, len(keys))
	for _, key := range keys {
		str := db.db.PropertyValue(key)
		stats[key] = str
	}
	return stats
}
447274
func (c Client) StatObject(bucketName, objectName string, opts StatObjectOptions) (ObjectInfo, error) {
	// Input validation.
	if err := s3utils.CheckValidBucketName(bucketName); err != nil {
		return ObjectInfo{}, err
	}
	if err := s3utils.CheckValidObjectName(objectName); err != nil {
		return ObjectInfo{}, err
	}
	return c.statObject(context.Background(), bucketName, objectName, opts)
}
601392
func (sto *overlayStorage) EnumerateBlobs(ctx context.Context, dest chan<- blob.SizedRef, after string, limit int) error {
	defer close(dest)

	enums := []blobserver.BlobEnumerator{sto.lower, sto.upper}

	// Ensure that we send limit blobs if possible.
	sent := 0
	for sent < limit {
		ch := make(chan blob.SizedRef)
		errch := make(chan error, 1)
		go func() {
			errch <- blobserver.MergedEnumerate(ctx, ch, enums, after, limit-sent)
		}()

		var last blob.Ref

		// Yield all blobs that weren't deleted from ch to destch.
		seen := 0
		for sbr := range ch {
			seen++
			if !sto.isDeleted(sbr.Ref) {
				log.Println(sent, sbr.Ref)
				dest <- sbr
				sent++
			}
			last = sbr.Ref
		}

		if err := <-errch; err != nil {
			return err
		}

		// if no blob was received, enumeration is finished
		if seen == 0 {
			return nil
		}

		// resume enumeration after the last blob seen
		after = last.String()
	}

	return nil
}
23555
func (c *Constraint) matchesAtMostOneBlob() blob.Ref {
	if c == nil {
		return blob.Ref{}
	}
	if c.BlobRefPrefix != "" {
		br, ok := blob.Parse(c.BlobRefPrefix)
		if ok {
			return br
		}
	}
	if c.Logical != nil && c.Logical.Op == "and" {
		if br := c.Logical.A.matchesAtMostOneBlob(); br.Valid() {
			return br
		}
		if br := c.Logical.B.matchesAtMostOneBlob(); br.Valid() {
			return br
		}
	}
	return blob.Ref{}
}
909946
func (c *Corpus) EnumerateSingleBlob(fn func(camtypes.BlobMeta) bool, br blob.Ref) {
	if bm := c.blobs[br]; bm != nil {
		fn(*bm)
	}
}
961930
func (c *Client) GetLunMaps() (Refs, error) {
	lunMaps, err := c.api.GetLunMaps()
	if err != nil {
		return nil, err
	}
	return lunMaps.LunMaps, nil
}
132388
func ReadBlob(length int32, data []byte) ([]byte, int64) {
	l := length
	if length > int32(len(data)) {
		l = int32(len(data))
	}

	var idx int32
	for idx = l; (idx % 4) != 0; idx++ {
		if idx >= int32(len(data)) {
			data = append(data, 0)
		}
	}
	return data[:idx], int64(idx)
}
1105223
func (s Secret) Blobs() []NamedBlob {
	out := make([]NamedBlob, 0, 1+len(s.Previous))
	out = append(out, s.Current)
	out = append(out, s.Previous...)
	return out
}
890130
func (dh *DownloadHandler) statFiles(refs []blob.Ref) error {
	statter, ok := dh.Fetcher.(blobserver.BlobStatter)
	if !ok {
		return fmt.Errorf("DownloadHandler.Fetcher %T is not a BlobStatter", dh.Fetcher)
	}
	statted := make(map[blob.Ref]bool)

	err := statter.StatBlobs(context.TODO(), refs, func(sb blob.SizedRef) error {
		statted[sb.Ref] = true
		return nil
	})
	if err != nil {
		log.Printf("Error statting blob files for download archive: %v", err)
		return fmt.Errorf("error looking for files")
	}
	for _, v := range refs {
		if _, ok := statted[v]; !ok {
			return fmt.Errorf("%q was not found", v)
		}
	}
	return nil
}
458853
func (sto *unionStorage) RemoveBlobs(ctx context.Context, blobs []blob.Ref) error {
	return blobserver.ErrReadonly
}
1185224
func (v *azureVolumeSource) listBlobs(ctx context.ProviderCallContext) ([]internalazurestorage.Blob, error) {
	blobsClient := v.maybeStorageClient.GetBlobService()
	vhdContainer := blobsClient.GetContainerReference(dataDiskVHDContainer)
	// TODO(axw) consider taking a set of IDs and computing the
	//           longest common prefix to pass in the parameters
	blobs, err := vhdContainer.Blobs()
	if err != nil {
		errorutils.HandleCredentialError(err, ctx)
		if err, ok := err.(azurestorage.AzureStorageServiceError); ok {
			switch err.Code {
			case "ContainerNotFound":
				return nil, nil
			}
		}
		return nil, errors.Annotate(err, "listing blobs")
	}
	return blobs, nil
}
1272293
func (z *Big) copyAbs(x *Big) *Big {
	if z != x {
		z.precision = x.Precision()
		z.exp = x.exp
		z.compact = x.compact
		if x.IsFinite() && x.isInflated() {
			z.unscaled.Set(&x.unscaled)
		}
	}
	z.form = x.form & ^signbit
	return z
}
1321218
func (c *CheckRunAnnotation) GetBlobHRef() string {
	if c == nil || c.BlobHRef == nil {
		return ""
	}
	return *c.BlobHRef
}