diff --git a/pkg/utils/filesize.go b/pkg/utils/filesize.go index 8b5dd4b..dc86630 100644 --- a/pkg/utils/filesize.go +++ b/pkg/utils/filesize.go @@ -6,6 +6,8 @@ import ( "path/filepath" "strconv" "strings" + + "github.com/pkg/errors" ) var sizeSuffixes = [...]string{"B", "KiB", "MiB", "GiB", "TiB"} @@ -30,7 +32,7 @@ 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 err + return errors.Wrapf(err, "failed to compute %s directory size", path) } dirSz += info.Size() @@ -39,7 +41,7 @@ func DirectorySize(path string) (dirSz int64, err error) { }) if err != nil { - return dirSz, err + return 0, err } return dirSz, nil