MCPcopy Index your code
hub / github.com/devspace-sh/devspace / writeTar

Method writeTar

helper/server/upstream.go:265–291  ·  view source on GitHub ↗
(writer io.WriteCloser, stream remote.Upstream_UploadServer)

Source from the content-addressed store, hash-verified

263}
264
265func (u *Upstream) writeTar(writer io.WriteCloser, stream remote.Upstream_UploadServer) error {
266 defer writer.Close()
267
268 // Receive file
269 for {
270 chunk, err := stream.Recv()
271 if chunk != nil {
272 n, err := writer.Write(chunk.Content)
273 if err != nil {
274 // this means the tar is done already, so we just exit here
275 if strings.Contains(err.Error(), "io: read/write on closed pipe") {
276 return nil
277 }
278
279 return err
280 } else if n != len(chunk.Content) {
281 return errors.Errorf("error writing data: bytes written %d != expected %d", n, len(chunk.Content))
282 }
283 }
284
285 if err == io.EOF {
286 return nil
287 } else if err != nil {
288 return err
289 }
290 }
291}
292
293func (u *Upstream) Execute(ctx context.Context, cmd *remote.Command) (*remote.Empty, error) {
294 if cmd.Once {

Callers 1

UploadMethod · 0.95

Calls 5

CloseMethod · 0.65
RecvMethod · 0.65
WriteMethod · 0.45
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected