MCPcopy
hub / github.com/kopia/kopia / output

Method output

cli/cli_progress.go:136–202  ·  view source on GitHub ↗
(col *color.Color, msg string)

Source from the content-addressed store, hash-verified

134}
135
136func (p *cliProgress) output(col *color.Color, msg string) {
137 p.outputMutex.Lock()
138 defer p.outputMutex.Unlock()
139
140 hashedBytes := p.hashedBytes.Load()
141 cachedBytes := p.cachedBytes.Load()
142 uploadedBytes := p.uploadedBytes.Load()
143 cachedFiles := p.cachedFiles.Load()
144 inProgressHashing := p.inProgressHashing.Load()
145 hashedFiles := p.hashedFiles.Load()
146 ignoredErrorCount := p.ignoredErrorCount.Load()
147 fatalErrorCount := p.fatalErrorCount.Load()
148
149 line := fmt.Sprintf(
150 " %v %v hashing, %v hashed (%v), %v cached (%v), uploaded %v",
151 p.spinnerCharacter(),
152
153 inProgressHashing,
154
155 hashedFiles,
156 units.BytesString(hashedBytes),
157
158 cachedFiles,
159 units.BytesString(cachedBytes),
160
161 units.BytesString(uploadedBytes),
162 )
163
164 if fatalErrorCount > 0 {
165 line += fmt.Sprintf(" (%v fatal errors)", fatalErrorCount)
166 }
167
168 if ignoredErrorCount > 0 {
169 line += fmt.Sprintf(" (%v errors ignored)", ignoredErrorCount)
170 }
171
172 if msg != "" {
173 prefix := "\n ! "
174 if !p.enableProgress {
175 prefix = ""
176 }
177
178 col.Fprintf(p.out.stderr(), "%v%v", prefix, msg) //nolint:errcheck
179 }
180
181 if !p.enableProgress {
182 return
183 }
184
185 if est, ok := p.uploadStartTime.Estimate(float64(hashedBytes+cachedBytes), float64(p.estimatedTotalBytes)); ok {
186 line += fmt.Sprintf(", estimated %v", units.BytesString(p.estimatedTotalBytes))
187 line += fmt.Sprintf(" (%.1f%%)", est.PercentComplete)
188 line += fmt.Sprintf(" %v left", est.Remaining)
189 } else {
190 line += ", estimating..."
191 }
192
193 var extraSpaces string

Callers 6

ErrorMethod · 0.95
maybeOutputMethod · 0.95
FinishSharedMethod · 0.95
FinishMethod · 0.95
runMethod · 0.45
runMethod · 0.45

Calls 9

spinnerCharacterMethod · 0.95
BytesStringFunction · 0.92
stderrMethod · 0.80
EstimateMethod · 0.80
RepeatMethod · 0.80
printStderrMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
LoadMethod · 0.65

Tested by

no test coverage detected