mirror of
https://github.com/restic/restic.git
synced 2025-03-09 00:00:02 +01:00
ui: restore: cleanup progress and summary report formatting and style
- use `%s` for strings consistently - add missing parens around skipped bytes in the summary report
This commit is contained in:
parent
afeca99aef
commit
47eb3d2cfe
2 changed files with 4 additions and 4 deletions
|
@ -25,10 +25,10 @@ func (t *textPrinter) Update(p State, duration time.Duration) {
|
|||
formattedAllBytesWritten := ui.FormatBytes(p.AllBytesWritten)
|
||||
formattedAllBytesTotal := ui.FormatBytes(p.AllBytesTotal)
|
||||
allPercent := ui.FormatPercent(p.AllBytesWritten, p.AllBytesTotal)
|
||||
progress := fmt.Sprintf("[%s] %s %v files/dirs %s, total %v files/dirs %v",
|
||||
progress := fmt.Sprintf("[%s] %s %v files/dirs %s, total %v files/dirs %s",
|
||||
timeLeft, allPercent, p.FilesFinished, formattedAllBytesWritten, p.FilesTotal, formattedAllBytesTotal)
|
||||
if p.FilesSkipped > 0 {
|
||||
progress += fmt.Sprintf(", skipped %v files/dirs %v", p.FilesSkipped, ui.FormatBytes(p.AllBytesSkipped))
|
||||
progress += fmt.Sprintf(", skipped %v files/dirs %s", p.FilesSkipped, ui.FormatBytes(p.AllBytesSkipped))
|
||||
}
|
||||
if p.FilesDeleted > 0 {
|
||||
progress += fmt.Sprintf(", deleted %v files/dirs", p.FilesDeleted)
|
||||
|
@ -83,7 +83,7 @@ func (t *textPrinter) Finish(p State, duration time.Duration) {
|
|||
p.FilesFinished, p.FilesTotal, formattedAllBytesWritten, formattedAllBytesTotal, timeLeft)
|
||||
}
|
||||
if p.FilesSkipped > 0 {
|
||||
summary += fmt.Sprintf(", skipped %v files/dirs %v", p.FilesSkipped, ui.FormatBytes(p.AllBytesSkipped))
|
||||
summary += fmt.Sprintf(", skipped %v files/dirs (%s)", p.FilesSkipped, ui.FormatBytes(p.AllBytesSkipped))
|
||||
}
|
||||
if p.FilesDeleted > 0 {
|
||||
summary += fmt.Sprintf(", deleted %v files/dirs", p.FilesDeleted)
|
||||
|
|
|
@ -42,7 +42,7 @@ func TestPrintSummaryOnErrors(t *testing.T) {
|
|||
func TestPrintSummaryOnSuccessWithSkipped(t *testing.T) {
|
||||
term, printer := createTextProgress()
|
||||
printer.Finish(State{11, 11, 2, 0, 47, 47, 59}, 5*time.Second)
|
||||
test.Equals(t, []string{"Summary: Restored 11 files/dirs (47 B) in 0:05, skipped 2 files/dirs 59 B"}, term.Output)
|
||||
test.Equals(t, []string{"Summary: Restored 11 files/dirs (47 B) in 0:05, skipped 2 files/dirs (59 B)"}, term.Output)
|
||||
}
|
||||
|
||||
func TestPrintCompleteItem(t *testing.T) {
|
||||
|
|
Loading…
Add table
Reference in a new issue