Upload implements the server upload interface and writes all the data received to a temporary file
(stream remote.Upstream_UploadServer)
| 239 | // Upload implements the server upload interface and writes all the data received to a |
| 240 | // temporary file |
| 241 | func (u *Upstream) Upload(stream remote.Upstream_UploadServer) error { |
| 242 | reader, writer := io.Pipe() |
| 243 | |
| 244 | defer reader.Close() |
| 245 | defer writer.Close() |
| 246 | |
| 247 | writerErrChan := make(chan error) |
| 248 | go func() { |
| 249 | writerErrChan <- u.writeTar(writer, stream) |
| 250 | }() |
| 251 | |
| 252 | err := untarAll(reader, u.options) |
| 253 | if err != nil { |
| 254 | return errors.Wrap(err, "untar all") |
| 255 | } |
| 256 | |
| 257 | err = <-writerErrChan |
| 258 | if err != nil { |
| 259 | return errors.Wrap(err, "write tar") |
| 260 | } |
| 261 | |
| 262 | return stream.SendAndClose(&remote.Empty{}) |
| 263 | } |
| 264 | |
| 265 | func (u *Upstream) writeTar(writer io.WriteCloser, stream remote.Upstream_UploadServer) error { |
| 266 | defer writer.Close() |
nothing calls this directly
no test coverage detected