MCPcopy
hub / github.com/rclone/rclone / GetCheckOpt

Function GetCheckOpt

cmd/check/check.go:80–135  ·  view source on GitHub ↗

GetCheckOpt gets the options corresponding to the check flags

(fsrc, fdst fs.Fs)

Source from the content-addressed store, hash-verified

78
79// GetCheckOpt gets the options corresponding to the check flags
80func GetCheckOpt(fsrc, fdst fs.Fs) (opt *operations.CheckOpt, close func(), err error) {
81 closers := []io.Closer{}
82
83 opt = &operations.CheckOpt{
84 Fsrc: fsrc,
85 Fdst: fdst,
86 OneWay: oneway,
87 }
88
89 open := func(name string, pout *io.Writer) error {
90 if name == "" {
91 return nil
92 }
93 if name == "-" {
94 *pout = os.Stdout
95 return nil
96 }
97 out, err := os.Create(name)
98 if err != nil {
99 return err
100 }
101 *pout = out
102 closers = append(closers, out)
103 return nil
104 }
105
106 if err = open(combined, &opt.Combined); err != nil {
107 return nil, nil, err
108 }
109 if err = open(missingOnSrc, &opt.MissingOnSrc); err != nil {
110 return nil, nil, err
111 }
112 if err = open(missingOnDst, &opt.MissingOnDst); err != nil {
113 return nil, nil, err
114 }
115 if err = open(match, &opt.Match); err != nil {
116 return nil, nil, err
117 }
118 if err = open(differ, &opt.Differ); err != nil {
119 return nil, nil, err
120 }
121 if err = open(errFile, &opt.Error); err != nil {
122 return nil, nil, err
123 }
124
125 close = func() {
126 for _, closer := range closers {
127 err := closer.Close()
128 if err != nil {
129 fs.Errorf(nil, "Failed to close report output: %v", err)
130 }
131 }
132 }
133
134 return opt, close, nil
135}
136
137var commandDefinition = &cobra.Command{

Callers 5

cryptCheckFunction · 0.92
checkconflictsMethod · 0.92
WhichEqualMethod · 0.92
checksum.goFile · 0.92
check.goFile · 0.85

Calls 4

ErrorfFunction · 0.92
openFunction · 0.85
CreateMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…