du: Fix double counting of objects (#3901)

`mc du play` would count objects twice since it was doing a recursive listing AND travering into folders.

Compare total to `mc du play --depth=2` and `mc du play --recursive`.
This commit is contained in:
Klaus Post
2021-12-22 08:21:52 -08:00
committed by GitHub
parent 385bc1b23a
commit 12012eafad
+2 -2
View File
@@ -24,7 +24,7 @@ import (
"strings"
"time"
humanize "github.com/dustin/go-humanize"
"github.com/dustin/go-humanize"
"github.com/fatih/color"
"github.com/minio/cli"
json "github.com/minio/colorjson"
@@ -151,7 +151,7 @@ func du(ctx context.Context, urlStr string, timeRef time.Time, withVersions bool
continue
}
if content.Type.IsDir() {
if content.Type.IsDir() && !recursive {
depth := depth
if depth > 0 {
depth--