Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Nick Craig-Wood
5476da476f size: make output compatible with -P
Before this change the output of `rclone size -P` would get corrupted
by the progress printing.

This is fixed by using operations.SyncPrintf instead of fmt.Printf.

Fixes #7912
2024-06-15 10:04:28 +01:00

View file

@ -4,7 +4,6 @@ package size
import (
"context"
"encoding/json"
"fmt"
"os"
"strconv"
@ -73,13 +72,13 @@ of the size command.
count := strconv.FormatInt(results.Count, 10)
countSuffix := fs.CountSuffix(results.Count).String()
if count == countSuffix {
fmt.Printf("Total objects: %s\n", count)
operations.SyncPrintf("Total objects: %s\n", count)
} else {
fmt.Printf("Total objects: %s (%s)\n", countSuffix, count)
operations.SyncPrintf("Total objects: %s (%s)\n", countSuffix, count)
}
fmt.Printf("Total size: %s (%d Byte)\n", fs.SizeSuffix(results.Bytes).ByteUnit(), results.Bytes)
operations.SyncPrintf("Total size: %s (%d Byte)\n", fs.SizeSuffix(results.Bytes).ByteUnit(), results.Bytes)
if results.Sizeless > 0 {
fmt.Printf("Total objects with unknown size: %s (%d)\n", fs.CountSuffix(results.Sizeless), results.Sizeless)
operations.SyncPrintf("Total objects with unknown size: %s (%d)\n", fs.CountSuffix(results.Sizeless), results.Sizeless)
}
return nil
})