// emptyTar pushes a compressed empty tar to the blob store if one doesn't
// already exist, and returns its blobsum.
974591
func (mb *configManifestBuilder) emptyTar(ctx context.Context) (digest.Digest, error) {
	if mb.emptyTarDigest != "" {
		// Already put an empty tar
		return mb.emptyTarDigest, nil
	}

	descriptor, err := mb.bs.Stat(ctx, digestSHA256GzippedEmptyTar)
	switch err {
	case nil:
		mb.emptyTarDigest = descriptor.Digest
		return descriptor.Digest, nil
	case distribution.ErrBlobUnknown:
		// nop
	default:
		return "", err
	}

	// Add gzipped empty tar to the blob store
	descriptor, err = mb.bs.Put(ctx, "", gzippedEmptyTar)
	if err != nil {
		return "", err
	}

	mb.emptyTarDigest = descriptor.Digest

	return descriptor.Digest, nil
}
394452
func (bb *Builder) Blob() *Blob {
	json, err := mapJSON(bb.m)
	if err != nil {
		panic(err)
	}
	ss, err := parseSuperset(strings.NewReader(json))
	if err != nil {
		panic(err)
	}
	h := blob.NewHash()
	h.Write([]byte(json))
	return &Blob{
		str: json,
		ss:  ss,
		br:  blob.RefFromHash(h),
	}
}
1264194
func (z *ZipArchive) AddEmptyDir(dirPath string) bool {
	if !strings.HasSuffix(dirPath, "/") {
		dirPath += "/"
	}

	for _, f := range z.files {
		if dirPath == f.Name {
			return false
		}
	}

	dirPath = strings.TrimSuffix(dirPath, "/")
	if strings.Contains(dirPath, "/") {
		// Auto add all upper level directories.
		z.AddEmptyDir(path.Dir(dirPath))
	}
	z.files = append(z.files, &File{
		FileHeader: &zip.FileHeader{
			Name:             dirPath + "/",
			UncompressedSize: 0,
		},
	})
	z.updateStat()
	return true
}
373806
func emptyDirSizeLimitInUse(podSpec *api.PodSpec) bool {
	if podSpec == nil {
		return false
	}
	for i := range podSpec.Volumes {
		if podSpec.Volumes[i].EmptyDir != nil {
			if podSpec.Volumes[i].EmptyDir.SizeLimit != nil {
				return true
			}
		}
	}
	return false
}
402071
func (ix *Index) populateDir(ctx context.Context, fetcher blob.Fetcher, b *schema.Blob, mm *mutationMap) error {
	blobRef := b.BlobRef()
	// TODO(bradfitz): move the NewDirReader and FileName method off *schema.Blob and onto
	// StaticFile/StaticDirectory or something.

	tf := &trackErrorsFetcher{f: fetcher.(*missTrackFetcher)}
	dr, err := b.NewDirReader(ctx, tf)
	if err != nil {
		// TODO(bradfitz): propagate up a transient failure
		// error type, so we can retry indexing files in the
		// future if blobs are only temporarily unavailable.
		log.Printf("index: error indexing directory, creating NewDirReader %s: %v", blobRef, err)
		return nil
	}
	sts, err := dr.StaticSet(ctx)
	if err != nil {
		if tf.hasErrNotExist() {
			return errMissingDep
		}
		log.Printf("index: error indexing directory: can't get StaticSet: %v\n", err)
		return nil
	}

	mm.Set(keyFileInfo.Key(blobRef), keyFileInfo.Val(len(sts), b.FileName(), "", blob.Ref{}))
	for _, br := range sts {
		mm.Set(keyStaticDirChild.Key(blobRef, br.String()), "1")
	}
	return nil
}
411947
func (rt ResourceTuple) Empty() bool {
	return rt.Cores == 0 && rt.Memory == 0 && rt.Disk == 0
}
641370
func (si *shareImporter) imprt(ctx context.Context, br blob.Ref) error {
	// A little less than the sniffer will take, so we don't truncate.
	const sniffSize = 900 * 1024
	select {
	case <-ctx.Done():
		return ctx.Err()
	default:
	}
	src := si.src
	dest := si.dest
	rc, _, err := src.Fetch(ctx, br)
	if err != nil {
		return err
	}
	rcc := types.NewOnceCloser(rc)
	defer rcc.Close()

	sniffer := index.NewBlobSniffer(br)
	_, err = io.CopyN(sniffer, rc, sniffSize)
	if err != nil && err != io.EOF {
		return err
	}
	sniffer.Parse()
	b, ok := sniffer.SchemaBlob()
	if !ok {
		return fmt.Errorf("%q: not a Perkeep schema.", br)
	}
	body, err := sniffer.Body()
	if err != nil {
		return err
	}
	rc = ioutil.NopCloser(io.MultiReader(bytes.NewReader(body), rc))

	switch b.Type() {
	case "directory":
		if _, err := blobserver.Receive(ctx, dest, br, rc); err != nil {
			return err
		}
		ssbr, ok := b.DirectoryEntries()
		if !ok {
			return fmt.Errorf("%q not actually a directory", br)
		}
		rcc.Close()
		return si.imprt(ctx, ssbr)
	case "static-set":
		if _, err := blobserver.Receive(ctx, dest, br, rc); err != nil {
			return err
		}
		rcc.Close()
		si.wg.Add(1)
		// asynchronous work assignment through w.workc
		go func() {
			defer si.wg.Done()
			si.mu.RLock()
			// do not pile in more work to do if there's already been an error
			if si.err != nil {
				si.mu.RUnlock()
				return
			}
			si.mu.RUnlock()
			var errcs []<-chan error
			for _, mref := range b.StaticSetMembers() {
				errc := make(chan error, 1)
				errcs = append(errcs, errc)
				si.workc <- work{mref, errc}
			}
			for _, errc := range errcs {
				if err := <-errc; err != nil {
					si.mu.Lock()
					si.err = err
					si.mu.Unlock()
				}
			}
		}()
		return nil
	case "file":
		rcc.Close()
		fr, err := schema.NewFileReader(ctx, src, br)
		if err != nil {
			return fmt.Errorf("NewFileReader: %v", err)
		}
		defer fr.Close()
		si.mu.Lock()
		si.seen++
		si.mu.Unlock()
		if _, err := schema.WriteFileMap(ctx, dest, b.Builder(), fr); err != nil {
			return err
		}
		si.mu.Lock()
		si.copied++
		si.mu.Unlock()
		return nil
	// TODO(mpl): other camliTypes, at least symlink.
	default:
		return errors.New("unknown blob type: " + b.Type())
	}
}
1336514
func (db *PublicRecord) EmptyTables() error {
	txSql := `DELETE FROM blocks;`
	_, err := db.conn.Exec(txSql)
	if err != nil {
		return err
	}
	return nil
}
950655
func (m *boxMap) LoadOrStore(key string, value *Box) (*Box, bool) {
	i, _ := m.data.LoadOrStore(key, value)
	s, ok := i.(*Box)
	return s, ok
}
876988
func (r *s3Repository) Blobs(ctx context.Context) distribution.BlobStore {
	return &s3BlobStore{r: r}
}
1121498
func Empty(t testing.TB, expr interface{}, args ...interface{}) {
	assert(t, IsEmpty(expr), args, []interface{}{"Empty 失败，实际值为[%T:%[1]v]", expr})
}
670777
func installGoTar(goTarGzPath string) error {
	installToPath := goToolkitInstallToPath()

	if err := os.RemoveAll(installToPath); err != nil {
		return fmt.Errorf("Failed to remove previous Go toolkit install (path: %s), error: %s", installToPath, err)
	}
	if err := pathutil.EnsureDirExist(installToPath); err != nil {
		return fmt.Errorf("Failed create Go toolkit directory (path: %s), error: %s", installToPath, err)
	}

	cmd := command.New("tar", "-C", installToPath, "-xzf", goTarGzPath)
	if combinedOut, err := cmd.RunAndReturnTrimmedCombinedOutput(); err != nil {
		log.Errorf(" [!] Failed to uncompress Go toolkit, output:")
		log.Errorf(combinedOut)
		return fmt.Errorf("Failed to uncompress Go toolkit, error: %s", err)
	}
	return nil
}
413142
func (u *UpdateStrategy) Empty() bool {
	if u == nil {
		return true
	}

	if u.Stagger != nil && *u.Stagger != 0 {
		return false
	}

	if u.MaxParallel != nil && *u.MaxParallel != 0 {
		return false
	}

	if u.HealthCheck != nil && *u.HealthCheck != "" {
		return false
	}

	if u.MinHealthyTime != nil && *u.MinHealthyTime != 0 {
		return false
	}

	if u.HealthyDeadline != nil && *u.HealthyDeadline != 0 {
		return false
	}

	if u.ProgressDeadline != nil && *u.ProgressDeadline != 0 {
		return false
	}

	if u.AutoRevert != nil && *u.AutoRevert {
		return false
	}

	if u.Canary != nil && *u.Canary != 0 {
		return false
	}

	return true
}
506215
func (c container) Blobs() ([]Blob, error) {
	//TODO(axw) handle pagination.
	resp, err := c.Container.ListBlobs(storage.ListBlobsParameters{})
	if err != nil {
		return nil, errors.Trace(err)
	}
	blobs := make([]Blob, len(resp.Blobs))
	for i := range blobs {
		blobs[i] = blob{&resp.Blobs[i]}
	}
	return blobs, nil
}
698465
func Empty(xu *xgbutil.XUtil) bool {
	xu.EvqueueLck.RLock()
	defer xu.EvqueueLck.RUnlock()

	return len(xu.Evqueue) == 0
}
1290708
func (p *PodContainer) EmptyEnvs() *PodContainer {
	p.Env = make(map[string]string)
	return p
}
517056
func (p *Pod) EmptyEnvs() *Pod {
	p.Env = make(map[string]string)
	return p
}