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