From 265d070255d22c8c1198241dd1f6cd3d8490882c Mon Sep 17 00:00:00 2001 From: Michael Eischer <9106997+MichaelEischer@users.noreply.github.com> Date: Fri, 15 May 2026 21:23:24 +0200 Subject: [PATCH] ui: Fix data race and minor API cleanup (#21801) --- internal/ui/restore/progress.go | 4 ++-- internal/ui/termstatus/status.go | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/ui/restore/progress.go b/internal/ui/restore/progress.go index fb3d5ad02..575c7e27d 100644 --- a/internal/ui/restore/progress.go +++ b/internal/ui/restore/progress.go @@ -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) } diff --git a/internal/ui/termstatus/status.go b/internal/ui/termstatus/status.go index 46357eca3..6f5f744e0 100644 --- a/internal/ui/termstatus/status.go +++ b/internal/ui/termstatus/status.go @@ -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}: