diff --git a/changelog/unreleased/issue-22112 b/changelog/unreleased/issue-22112 new file mode 100644 index 000000000..1e077a92e --- /dev/null +++ b/changelog/unreleased/issue-22112 @@ -0,0 +1,10 @@ +Bugfix: Fix `stats` progress bar resetting its counters for every snapshot + +The progress bar of `restic stats` reset its file, blob and size counters +at the start of each snapshot, so the final progress line only showed the +numbers for the last processed snapshot. These numbers varied between runs +depending on the order in which snapshots were processed. The progress bar +now counts across all selected snapshots. + +https://github.com/restic/restic/issues/22112 +https://github.com/restic/restic/pull/22130 diff --git a/internal/ui/stats/progress.go b/internal/ui/stats/progress.go index 5f568070e..cace6a8c5 100644 --- a/internal/ui/stats/progress.go +++ b/internal/ui/stats/progress.go @@ -88,7 +88,4 @@ func (p *Progress) ProcessSnapshot() { defer p.m.Unlock() p.processedSnapshotCount++ - p.processedFileCount = 0 - p.processedBlobCount = 0 - p.processedSize = 0 } diff --git a/internal/ui/stats/progress_test.go b/internal/ui/stats/progress_test.go index 2508d0056..aed19282e 100644 --- a/internal/ui/stats/progress_test.go +++ b/internal/ui/stats/progress_test.go @@ -24,14 +24,14 @@ func TestStatsProgress(t *testing.T) { progress.ProcessSnapshot() progress.printProgress(10*time.Second, false) - rtest.Equals(t, []string{"[0:10] 50.00% 2 / 2 snapshots, 0 B"}, term.Output) + rtest.Equals(t, []string{"[0:10] 50.00% 2 / 2 snapshots, 1 files, 2 blobs, 3 B"}, term.Output) progress.Update(4, 5, 6) progress.printProgress(15*time.Second, false) - rtest.Equals(t, []string{"[0:15] 50.00% 2 / 2 snapshots, 4 files, 5 blobs, 6 B"}, term.Output) + rtest.Equals(t, []string{"[0:15] 50.00% 2 / 2 snapshots, 5 files, 7 blobs, 9 B"}, term.Output) progress.printProgress(20*time.Second, true) - rtest.Equals(t, []string{"[0:20] 100.00% 2 / 2 snapshots, 4 files, 5 blobs, 6 B"}, term.Output) + rtest.Equals(t, []string{"[0:20] 100.00% 2 / 2 snapshots, 5 files, 7 blobs, 9 B"}, term.Output) } func TestStatsProgressJSON(t *testing.T) {