code: func (lum *LayerUploadManager) Upload(ctx context.Context, layers []UploadDescriptor, progressOutput progress.Output) error {
  	var (
  		uploads          []*uploadTransfer
  		dedupDescriptors = make(map[string]*uploadTransfer)
  	)
  
  	for _, descriptor := range layers {
  		progress.Update(progressOutput, descriptor.ID(), "Preparing")
  
  		key := descriptor.Key()
  		if _, present := dedupDescriptors[key]; present {
  			continue
  		}
  
  		xferFunc := lum.makeUploadFunc(descriptor)
  		upload, watcher := lum.tm.Transfer(descriptor.Key(), xferFunc, progressOutput)
  		defer upload.Release(watcher)
  		uploads = append(uploads, upload.(*uploadTransfer))
  		dedupDescriptors[key] = upload.(*uploadTransfer)
  	}
  
  	for _, upload := range uploads {
  		select {
  		case <-ctx.Done():
  			return ctx.Err()
  		case <-upload.Transfer.Done():
  			if upload.err != nil {
  				return upload.err
  			}
  		}
  	}
  	for _, l := range layers {
  		l.SetRemoteDescriptor(dedupDescriptors[l.Key()].remoteDescriptor)
  	}
  
  	return nil
  }
docs: // Upload is a blocking function which ensures the listed layers are present on
  // the remote registry. It uses the string returned by the Key method to
  // deduplicate uploads.