MCPcopy
hub / github.com/lxc/incus / Recv

Function Recv

internal/rsync/rsync.go:310–415  ·  view source on GitHub ↗

Recv sets up the receiving half of the websocket to rsync (the other half set up by rsync.Send), putting the contents in the directory specified by path.

(path string, conn io.ReadWriteCloser, tracker *ioprogress.ProgressTracker, features []string)

Source from the content-addressed store, hash-verified

308// half set up by rsync.Send), putting the contents in the directory specified
309// by path.
310func Recv(path string, conn io.ReadWriteCloser, tracker *ioprogress.ProgressTracker, features []string) error {
311 args := []string{
312 "--server",
313 "-vlogDtpre.iLsfx",
314 "--numeric-ids",
315 "--devices",
316 "--partial",
317 "--sparse",
318 // This flag is only required on the receiving end.
319 // Checks for file modifications on nanoseconds granularity.
320 "--modify-window=-1",
321 }
322
323 if len(features) > 0 {
324 args = append(args, rsyncFeatureArgs(features)...)
325 }
326
327 args = append(args, []string{".", path}...)
328
329 cmd := exec.Command("rsync", args...)
330
331 // Call the wrapper if defined.
332 if RunWrapper != nil {
333 cleanup, err := RunWrapper(cmd, "", path)
334 if err != nil {
335 return err
336 }
337
338 defer cleanup()
339 }
340
341 // Forward from rsync to source.
342 stdout, err := cmd.StdoutPipe()
343 if err != nil {
344 return err
345 }
346
347 chCopyRsync := make(chan error, 1)
348 go func() {
349 _, err := util.SafeCopy(conn, stdout)
350 _ = stdout.Close()
351 _ = conn.Close() // sends barrier message.
352 chCopyRsync <- err
353 }()
354
355 // Forward from source to rsync.
356 stdin, err := cmd.StdinPipe()
357 if err != nil {
358 return err
359 }
360
361 readSourcePipe := io.ReadCloser(conn)
362 if tracker != nil {
363 readSourcePipe = &ioprogress.ProgressReader{
364 ReadCloser: conn,
365 Tracker: tracker,
366 }
367 }

Calls 9

SafeCopyFunction · 0.92
ErrorfFunction · 0.92
rsyncFeatureArgsFunction · 0.85
CommandMethod · 0.80
ErrorfMethod · 0.80
CloseMethod · 0.65
StartMethod · 0.65
WaitMethod · 0.65
KillMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…