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

Function rsync

internal/rsync/rsync.go:31–63  ·  view source on GitHub ↗

rsync is a wrapper for the rsync command which will respect RunWrapper.

(args ...string)

Source from the content-addressed store, hash-verified

29
30// rsync is a wrapper for the rsync command which will respect RunWrapper.
31func rsync(args ...string) (string, error) {
32 if len(args) < 2 {
33 return "", errors.New("rsync call expects a minimum of two arguments (source and destination)")
34 }
35
36 // Setup the command.
37 cmd := exec.Command("rsync", args...)
38 var stderr bytes.Buffer
39 cmd.Stderr = &stderr
40 var stdout bytes.Buffer
41 cmd.Stdout = &stdout
42
43 // Call the wrapper if defined.
44 if RunWrapper != nil {
45 source := args[len(args)-2]
46 destination := args[len(args)-1]
47
48 cleanup, err := RunWrapper(cmd, source, destination)
49 if err != nil {
50 return "", err
51 }
52
53 defer cleanup()
54 }
55
56 // Run the command.
57 err := cmd.Run()
58 if err != nil {
59 return stdout.String(), subprocess.NewRunError("rsync", args, err, &stdout, &stderr)
60 }
61
62 return stdout.String(), nil
63}
64
65// LocalCopy copies a directory using rsync (with the --devices option).
66func LocalCopy(source string, dest string, bwlimit string, xattrs bool, rsyncArgs ...string) (string, error) {

Callers 1

LocalCopyFunction · 0.85

Calls 4

NewRunErrorFunction · 0.92
CommandMethod · 0.80
StringMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…