mirror of
https://github.com/restic/restic.git
synced 2026-05-15 22:55:24 +00:00
ui: Fix data race and minor API cleanup (#21801)
This commit is contained in:
@@ -131,11 +131,11 @@ func (p *Progress) ReportDeletion(name string) {
|
||||
return
|
||||
}
|
||||
|
||||
p.s.FilesDeleted++
|
||||
|
||||
p.m.Lock()
|
||||
defer p.m.Unlock()
|
||||
|
||||
p.s.FilesDeleted++
|
||||
|
||||
p.printer.CompleteItem(ActionDeleted, name, 0)
|
||||
}
|
||||
|
||||
|
||||
@@ -394,15 +394,16 @@ func (t *Terminal) Error(line string) {
|
||||
}
|
||||
|
||||
func sanitizeLines(lines []string, width int) []string {
|
||||
sanitized := make([]string, len(lines))
|
||||
// Sanitize lines and truncate them if they're too long.
|
||||
for i, line := range lines {
|
||||
line = ui.Quote(line)
|
||||
if width > 0 {
|
||||
line = ui.Truncate(line, width-2)
|
||||
}
|
||||
lines[i] = line
|
||||
sanitized[i] = line
|
||||
}
|
||||
return lines
|
||||
return sanitized
|
||||
}
|
||||
|
||||
// SetStatus updates the status lines.
|
||||
@@ -419,7 +420,7 @@ func (t *Terminal) SetStatus(lines []string) {
|
||||
}
|
||||
}
|
||||
|
||||
sanitizeLines(lines, width)
|
||||
lines = sanitizeLines(lines, width)
|
||||
|
||||
select {
|
||||
case t.status <- status{lines: lines}:
|
||||
|
||||
Reference in New Issue
Block a user