code: func (bw *blobWriter) removeResources(ctx context.Context) error {
  	dataPath, err := pathFor(uploadDataPathSpec{
  		name: bw.blobStore.repository.Named().Name(),
  		id:   bw.id,
  	})
  
  	if err != nil {
  		return err
  	}
  
  	// Resolve and delete the containing directory, which should include any
  	// upload related files.
  	dirPath := path.Dir(dataPath)
  	if err := bw.blobStore.driver.Delete(ctx, dirPath); err != nil {
  		switch err := err.(type) {
  		case storagedriver.PathNotFoundError:
  			break // already gone!
  		default:
  			// This should be uncommon enough such that returning an error
  			// should be okay. At this point, the upload should be mostly
  			// complete, but perhaps the backend became unaccessible.
  			dcontext.GetLogger(ctx).Errorf("unable to delete layer upload resources %q: %v", dirPath, err)
  			return err
  		}
  	}
  
  	return nil
  }
docs: // removeResources should clean up all resources associated with the upload
  // instance. An error will be returned if the clean up cannot proceed. If the
  // resources are already not present, no error will be returned.