diff --git a/pkg/utils/filesize.go b/pkg/utils/filesize.go index d58a0c4..be9f553 100644 --- a/pkg/utils/filesize.go +++ b/pkg/utils/filesize.go @@ -29,19 +29,15 @@ func ConvertFileSize(size int64) (float64, string, string) { } func DirectorySize(path string) (dirSz int64, err error) { - err = filepath.Walk(path, func(_ string, info fs.FileInfo, err error) error { - if err != nil { - return errors.Wrapf(err, "failed to compute %s directory size", path) - } - - dirSz += info.Size() - - return nil - }) - + dir, err := ioutil.ReadDir(path) if err != nil { - return 0, err + return 0, errors.Wrapf(err, "failed to compute %s directory size", path) } + for _, entry := range dir { + dirSz += entry.Size() + } + + // Here we subtract a size of a directory's inode to get size of files only. return dirSz - 4096, nil }