mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 04:45:15 +00:00
Tweak restore summary
This commit is contained in:
parent
6e586b64e4
commit
2657217574
@ -22,7 +22,7 @@ func (t *textPrinter) Update(filesFinished, filesTotal, allBytesWritten, allByte
|
|||||||
formattedAllBytesWritten := ui.FormatBytes(allBytesWritten)
|
formattedAllBytesWritten := ui.FormatBytes(allBytesWritten)
|
||||||
formattedAllBytesTotal := ui.FormatBytes(allBytesTotal)
|
formattedAllBytesTotal := ui.FormatBytes(allBytesTotal)
|
||||||
allPercent := ui.FormatPercent(allBytesWritten, allBytesTotal)
|
allPercent := ui.FormatPercent(allBytesWritten, allBytesTotal)
|
||||||
progress := fmt.Sprintf("[%s] %s %v files %s, total %v files %v",
|
progress := fmt.Sprintf("[%s] %s %v files/dirs %s, total %v files/dirs %v",
|
||||||
timeLeft, allPercent, filesFinished, formattedAllBytesWritten, filesTotal, formattedAllBytesTotal)
|
timeLeft, allPercent, filesFinished, formattedAllBytesWritten, filesTotal, formattedAllBytesTotal)
|
||||||
|
|
||||||
t.terminal.SetStatus([]string{progress})
|
t.terminal.SetStatus([]string{progress})
|
||||||
@ -36,10 +36,10 @@ func (t *textPrinter) Finish(filesFinished, filesTotal, allBytesWritten, allByte
|
|||||||
|
|
||||||
var summary string
|
var summary string
|
||||||
if filesFinished == filesTotal && allBytesWritten == allBytesTotal {
|
if filesFinished == filesTotal && allBytesWritten == allBytesTotal {
|
||||||
summary = fmt.Sprintf("Summary: Restored %d Files (%s) in %s", filesTotal, formattedAllBytesTotal, timeLeft)
|
summary = fmt.Sprintf("Summary: Restored %d files/dirs (%s) in %s", filesTotal, formattedAllBytesTotal, timeLeft)
|
||||||
} else {
|
} else {
|
||||||
formattedAllBytesWritten := ui.FormatBytes(allBytesWritten)
|
formattedAllBytesWritten := ui.FormatBytes(allBytesWritten)
|
||||||
summary = fmt.Sprintf("Summary: Restored %d / %d Files (%s / %s) in %s",
|
summary = fmt.Sprintf("Summary: Restored %d / %d files/dirs (%s / %s) in %s",
|
||||||
filesFinished, filesTotal, formattedAllBytesWritten, formattedAllBytesTotal, timeLeft)
|
filesFinished, filesTotal, formattedAllBytesWritten, formattedAllBytesTotal, timeLeft)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,19 +23,19 @@ func TestPrintUpdate(t *testing.T) {
|
|||||||
term := &mockTerm{}
|
term := &mockTerm{}
|
||||||
printer := NewTextProgress(term)
|
printer := NewTextProgress(term)
|
||||||
printer.Update(3, 11, 29, 47, 5*time.Second)
|
printer.Update(3, 11, 29, 47, 5*time.Second)
|
||||||
test.Equals(t, []string{"[0:05] 61.70% 3 files 29 B, total 11 files 47 B"}, term.output)
|
test.Equals(t, []string{"[0:05] 61.70% 3 files/dirs 29 B, total 11 files/dirs 47 B"}, term.output)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrintSummaryOnSuccess(t *testing.T) {
|
func TestPrintSummaryOnSuccess(t *testing.T) {
|
||||||
term := &mockTerm{}
|
term := &mockTerm{}
|
||||||
printer := NewTextProgress(term)
|
printer := NewTextProgress(term)
|
||||||
printer.Finish(11, 11, 47, 47, 5*time.Second)
|
printer.Finish(11, 11, 47, 47, 5*time.Second)
|
||||||
test.Equals(t, []string{"Summary: Restored 11 Files (47 B) in 0:05"}, term.output)
|
test.Equals(t, []string{"Summary: Restored 11 files/dirs (47 B) in 0:05"}, term.output)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrintSummaryOnErrors(t *testing.T) {
|
func TestPrintSummaryOnErrors(t *testing.T) {
|
||||||
term := &mockTerm{}
|
term := &mockTerm{}
|
||||||
printer := NewTextProgress(term)
|
printer := NewTextProgress(term)
|
||||||
printer.Finish(3, 11, 29, 47, 5*time.Second)
|
printer.Finish(3, 11, 29, 47, 5*time.Second)
|
||||||
test.Equals(t, []string{"Summary: Restored 3 / 11 Files (29 B / 47 B) in 0:05"}, term.output)
|
test.Equals(t, []string{"Summary: Restored 3 / 11 files/dirs (29 B / 47 B) in 0:05"}, term.output)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user