docker/tarfile/dest.go
func (d *Destination) sendFile(path string, expectedSize int64, stream io.Reader) error {
	hdr, err := tar.FileInfoHeader(&tarFI{path: path, size: expectedSize}, "")
	if err != nil {
		return nil
	}
	logrus.Debugf("Sending as tar file %s", path)
	if err := d.tar.WriteHeader(hdr); err != nil {
		return err
	}
	// TODO: This can take quite some time, and should ideally be cancellable using a context.Context.
	size, err := io.Copy(d.tar, stream)
	if err != nil {
		return err
	}
	if size != expectedSize {
		return errors.Errorf("Size mismatch when copying %s, expected %d, got %d", path, expectedSize, size)
	}
	return nil
}
func (d *Destination) sendFile(path string, expectedSize int64, stream io.Reader) error {
	hdr, err := tar.FileInfoHeader(&tarFI{path: path, size: expectedSize}, "")
	if err != nil {
		return nil
	}
	logrus.Debugf("Sending as tar file %s", path)
	if err := d.tar.WriteHeader(hdr); err != nil {
		return err
	}
	// TODO: This can take quite some time, and should ideally be cancellable using a context.Context.
	size, err := io.Copy(d.tar, stream)
	if err != nil {
		return err
	}
	if size != expectedSize {
		return errors.Errorf("Size mismatch when copying %s, expected %d, got %d", path, expectedSize, size)
	}
	return nil
}
func ( d * Destination ) sendFile ( path string , expectedSize int64 , stream io . Reader ) error { hdr , err := tar . FileInfoHeader ( & tarFI { path : path , size : expectedSize } , " " ) if err != nil { return nil } logrus . Debugf ( " " , path ) if err := d . tar . WriteHeader ( hdr ) ; err != nil { return err } // TODO: This can take quite some time, and should ideally be cancellable using a context.Context. size , err := io . Copy ( d . tar , stream ) if err != nil { return err } if size != expectedSize { return errors . Errorf ( " " , path , expectedSize , size ) } return nil }
// sendFile sends a file into the tar stream.
sendFile sends a file into the tar stream .