forked from TrueCloudLab/restic
stats: only check for hardlinks for files with more than one link
This commit is contained in:
parent
21cf38fe96
commit
cf81f8ced6
2 changed files with 8 additions and 4 deletions
|
@ -4,4 +4,5 @@ If files on different devices had the same inode id, then the `stats` command
|
||||||
did not correctly calculate the snapshot size. This has been fixed.
|
did not correctly calculate the snapshot size. This has been fixed.
|
||||||
|
|
||||||
https://github.com/restic/restic/pull/4503
|
https://github.com/restic/restic/pull/4503
|
||||||
|
https://github.com/restic/restic/pull/4006
|
||||||
https://forum.restic.net/t/possible-bug-in-stats/6461/8
|
https://forum.restic.net/t/possible-bug-in-stats/6461/8
|
||||||
|
|
|
@ -270,11 +270,14 @@ func statsWalkTree(repo restic.Loader, opts StatsOptions, stats *statsContainer,
|
||||||
// will still be restored
|
// will still be restored
|
||||||
stats.TotalFileCount++
|
stats.TotalFileCount++
|
||||||
|
|
||||||
// if inodes are present, only count each inode once
|
if node.Links == 1 || node.Type == "dir" {
|
||||||
// (hard links do not increase restore size)
|
|
||||||
if !hardLinkIndex.Has(node.Inode, node.DeviceID) || node.Inode == 0 {
|
|
||||||
hardLinkIndex.Add(node.Inode, node.DeviceID, struct{}{})
|
|
||||||
stats.TotalSize += node.Size
|
stats.TotalSize += node.Size
|
||||||
|
} else {
|
||||||
|
// if hardlinks are present only count each deviceID+inode once
|
||||||
|
if !hardLinkIndex.Has(node.Inode, node.DeviceID) || node.Inode == 0 {
|
||||||
|
hardLinkIndex.Add(node.Inode, node.DeviceID, struct{}{})
|
||||||
|
stats.TotalSize += node.Size
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue