optimize
This commit is contained in:
parent
51c2d40639
commit
7b9d02491f
|
@ -188,14 +188,15 @@ func (fs *Filesystem) DirectorySize(dir string) (int64, error) {
|
||||||
if !e.IsDir() {
|
if !e.IsDir() {
|
||||||
_ = syscall.Lstat(p, &st)
|
_ = syscall.Lstat(p, &st)
|
||||||
|
|
||||||
|
if st.Nlink > 1 {
|
||||||
// Hard links have the same inode number
|
// Hard links have the same inode number
|
||||||
if slices.Contains(hardLinks, st.Ino) {
|
if slices.Contains(hardLinks, st.Ino) {
|
||||||
// Don't add hard links size twice
|
// Don't add hard links size twice
|
||||||
return godirwalk.SkipThis
|
return godirwalk.SkipThis
|
||||||
}
|
} else {
|
||||||
if st.Nlink > 1 {
|
|
||||||
hardLinks = append(hardLinks, st.Ino)
|
hardLinks = append(hardLinks, st.Ino)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
atomic.AddInt64(&size, st.Size)
|
atomic.AddInt64(&size, st.Size)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user