From 23055aaadfa2a89f4bc3db3a1e8368002a1213f5 Mon Sep 17 00:00:00 2001 From: David Potter Date: Tue, 7 Jan 2020 10:33:58 -0800 Subject: [PATCH] Correct #2537 (cmd_stats file counting issue) --- changelog/unreleased/issue-2537 | 5 +++++ cmd/restic/cmd_stats.go | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/issue-2537 diff --git a/changelog/unreleased/issue-2537 b/changelog/unreleased/issue-2537 new file mode 100644 index 000000000..6e639d552 --- /dev/null +++ b/changelog/unreleased/issue-2537 @@ -0,0 +1,5 @@ +Bugfix: Fix incorrect file counts in `stats --mode restore-size` + +The restore-size mode of stats was failing to count empty directories and some files with hard links. + +https://github.com/restic/restic/issues/2537 diff --git a/cmd/restic/cmd_stats.go b/cmd/restic/cmd_stats.go index a202fd029..5306082bf 100644 --- a/cmd/restic/cmd_stats.go +++ b/cmd/restic/cmd_stats.go @@ -247,8 +247,13 @@ func statsWalkTree(repo restic.Repository, stats *statsContainer) walker.WalkFun // as this is a file in the snapshot, we can simply count its // size without worrying about uniqueness, since duplicate files // will still be restored - stats.TotalSize += node.Size stats.TotalFileCount++ + + // TODO - Issue #2531 Handle hard links by identifying duplicate inodes. + // (Duplicates should appear in the file count, but not the size count) + stats.TotalSize += node.Size + + return false, nil } return true, nil