size: dont show duplicate object count when less than 1k

This commit is contained in:
albertony 2023-11-03 20:33:59 +01:00 committed by Nick Craig-Wood
parent acf1e2df84
commit e1b0417c28

View File

@ -6,6 +6,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"os" "os"
"strconv"
"github.com/rclone/rclone/cmd" "github.com/rclone/rclone/cmd"
"github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs"
@ -69,7 +70,13 @@ of the size command.
if jsonOutput { if jsonOutput {
return json.NewEncoder(os.Stdout).Encode(results) return json.NewEncoder(os.Stdout).Encode(results)
} }
fmt.Printf("Total objects: %s (%d)\n", fs.CountSuffix(results.Count), results.Count) count := strconv.FormatInt(results.Count, 10)
countSuffix := fs.CountSuffix(results.Count).String()
if count == countSuffix {
fmt.Printf("Total objects: %s\n", count)
} else {
fmt.Printf("Total objects: %s (%s)\n", countSuffix, count)
}
fmt.Printf("Total size: %s (%d Byte)\n", fs.SizeSuffix(results.Bytes).ByteUnit(), results.Bytes) fmt.Printf("Total size: %s (%d Byte)\n", fs.SizeSuffix(results.Bytes).ByteUnit(), results.Bytes)
if results.Sizeless > 0 { if results.Sizeless > 0 {
fmt.Printf("Total objects with unknown size: %s (%d)\n", fs.CountSuffix(results.Sizeless), results.Sizeless) fmt.Printf("Total objects with unknown size: %s (%d)\n", fs.CountSuffix(results.Sizeless), results.Sizeless)