INNER CODE UNIT · Go

uploadHashLayer

tazjin/nixery · builder/builder.go:368

func uploadHashLayer(ctx context.Context, s *State, key string, mrating uint64, lw layerWriter) (*manifest.Entry, error) {
	s.UploadMutex.Lock(key)
	defer s.UploadMutex.Unlock(key)

	if entry, cached := layerFromCache(ctx, s, key); cached {
		return entry, nil
	}

	path := "staging/" + key
	var tarhash string
	sha256sum, size, err := s.Storage.Persist(ctx, path, manifest.LayerType, func(sw io.Writer) (string, int64, error) {
		// Sets up a "multiwriter" that simultaneously runs both hash
		// algorithms and uploads to the storage backend.
		shasum := sha256.New()
		counter := &byteCounter{}
		multi := io.MultiWriter(sw, shasum, counter)

		var err error

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…