From 7c084014fa5b605a42bc198e4c959b0984de716a Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 6 Jan 2019 13:15:23 +0100 Subject: [PATCH] Use processed bytes for summary When restic reads the backup from stdin, the number of bytes processed was always displayed as zero. The reason is that the UI for the archive uses the total bytes as returned by the scanner, which is zero for stdin. So instead we keep track of the real number of bytes processed and print that at the end. Closes #2136 --- internal/ui/backup.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/ui/backup.go b/internal/ui/backup.go index 3a950d9ad..18f9f4f93 100644 --- a/internal/ui/backup.go +++ b/internal/ui/backup.go @@ -49,6 +49,7 @@ type Backup struct { Changed uint Unchanged uint } + ProcessedBytes uint64 archiver.ItemStats } } @@ -259,6 +260,12 @@ func formatBytes(c uint64) string { func (b *Backup) CompleteItemFn(item string, previous, current *restic.Node, s archiver.ItemStats, d time.Duration) { b.summary.Lock() b.summary.ItemStats.Add(s) + + // for the last item "/", current is nil + if current != nil { + b.summary.ProcessedBytes += current.Size + } + b.summary.Unlock() if current == nil { @@ -361,7 +368,7 @@ func (b *Backup) Finish() { b.P("\n") b.P("processed %v files, %v in %s", b.summary.Files.New+b.summary.Files.Changed+b.summary.Files.Unchanged, - formatBytes(b.totalBytes), + formatBytes(b.summary.ProcessedBytes), formatDuration(time.Since(b.start)), ) }